RosettaCodeData/Task/Numerical-integration/MATLAB/numerical-integration-2.m

9 lines
213 B
Mathematica
Raw Permalink Normal View History

2013-04-10 23:57:08 -07:00
function integral = rightRectIntegration(f,a,b,n)
format long;
width = (b-a)/n; %calculate the width of each devision
x = linspace(a,b,n); %define x-axis
integral = width * sum( f(x(2:n)) );
end