# Thread: Help with calculating integral in MATLAB

1. ## 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.

2. 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.

3. 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