Help with calculating integral in MATLAB

• Nov 30th 2009, 02:47 AM
Chazed
Help with calculating integral in MATLAB
Hey there people! This will probably be easy for you.. But not for me! I am new to the program MATLAB (reading a course where I have to use it). I´ve been googling some and tried other ways to get help, but without results.

I want to make an M-file that calculates the definite integral of ∫x3 dx in the interval 3 – 1.

All help is appriciated!

Regards, Chazed.
• Nov 30th 2009, 03:57 AM
elbarto
Do u want to calculate it using your own numerical methods or buy using matlabs symbolic tool kit. Matlabs has it's own numerical implementation of simpsons rule to I think. Sorry I don't have matlabs with me right now so can't post an example.
• Nov 30th 2009, 04:15 AM
CaptainBlack
Quote:

Originally Posted by Chazed
Hey there people! This will probably be easy for you.. But not for me! I am new to the program MATLAB (reading a course where I have to use it). I´ve been googling some and tried other ways to get help, but without results.

I want to make an M-file that calculates the definite integral of ∫x3 dx in the interval 3 – 1.

All help is appriciated!

Regards, Chazed.

Midpoint rule:

Code:

```dx=0.001; x=1+dx/2:dx:3 ii=x.^3; II=sum(ii)*dx;```
and if you really mean to do the integral from 3 to 1 the answer is minus the above.

CB