Mid-ordinate Rule For Polynomial equation - Numerical Integration
Afficher commentaires plus anciens
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 commentaires
Star Strider
le 12 Juin 2014
‘I'm getting a series of errors’...
Care to elaborate on that?
MATLAB
le 12 Juin 2014
MATLAB
le 12 Juin 2014
Réponses (0)
Catégories
En savoir plus sur Numerical Integration and Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!