Mid-ordinate Rule For Polynomial equation - Numerical Integration
Mostrar comentarios más antiguos
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 comentarios
Star Strider
el 12 de Jun. de 2014
‘I'm getting a series of errors’...
Care to elaborate on that?
MATLAB
el 12 de Jun. de 2014
MATLAB
el 12 de Jun. de 2014
Respuestas (0)
Categorías
Más información sobre Numerical Integration and Differential Equations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!