Mid-ordinate Rule For Polynomial equation - Numerical Integration

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

‘I'm getting a series of errors’...
Care to elaborate on that?
It says unable to plot, error on line: plot(x,(xf),x,If)
the f Polynomial for testing should actually state: ax^4+bx^3+cx^2+dx+e

Sign in to comment.

Answers (0)

Categories

Find more on Numerical Integration and Differential Equations in Help Center and File Exchange

Asked:

on 11 Jun 2014

Commented:

on 12 Jun 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!