Mid-ordinate Rule For Polynomial equation - Numerical Integration
2 views (last 30 days)
Show older comments
Im a beginner on MATLAB and have this question in an assignment,, I have no idea how to do this:
Write a user defined documented function in MATLAB to perform numerical integration using Mid-Ordinate rule. The function should allow for parameters to be passed, for the function, Limits of integration and the number of strips.
The function is required to return the mean, area, minimum and maximum values.
The function should be tested using a polynomial equation:
ax4+bx3+cx2+dx+e
so far I've found this online but i'm getting a series of errors, I would be grateful for any help:
function [ area ] = midordinate( f,xl,xu,dx )
%f=function
%xl = Lower limit
%xu = Upper limit
%dx = width of strip / rectangle
%area = total area under curve
num=(xu-xl)/dx
a=xl;
x=xl:dx:xu;
for ii=1:1:num
b=a+dx
M(ii)=(b-a)*f((a+b))/2;
If(ii)=sum(M);
a=b;
end
plot(x,(xf),x,If)
area=sum(M);
end
3 Comments
Answers (0)
See Also
Categories
Find more on Polynomials in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!