Mid-ordinate Rule For Polynomial equation - Numerical Integration
Ältere Kommentare anzeigen
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 Kommentare
Star Strider
am 12 Jun. 2014
‘I'm getting a series of errors’...
Care to elaborate on that?
MATLAB
am 12 Jun. 2014
MATLAB
am 12 Jun. 2014
Antworten (0)
Kategorien
Mehr zu Numerical Integration and Differential Equations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!