# Math Help - Matlab help

1. ## Matlab help

Can anyone sohw me how to do Riemann Integrals Sums on matlab.

The question I have to do is this:

Using Matlab, calculate an approximation for the definite integral of
g(x)
= 2 − x^3 on the interval [0,4] using 100 equal subintervals.

What I do is use the command

rsums(2-x^3,0,4)
Then I move the bottom to 100 (so that there are 100 subintervals) And on the top it gives me -13.999200

Is this right? It doesnt seem right. Shouldnt the approximation be closer to -56 (which is what the exact signed area is)? And is there any other way to do it?

2. Originally Posted by Johnaloa
Can anyone sohw me how to do Riemann Integrals Sums on matlab.

The question I have to do is this:

Using Matlab, calculate an approximation for the definite integral of

g(x)
= 2 − x^3 on the interval [0,4] using 100 equal subintervals.

What I do is use the command

rsums(2-x^3,0,4)
Then I move the bottom to 100 (so that there are 100 subintervals) And on the top it gives me -13.999200

Is this right? It doesnt seem right. Shouldnt the approximation be closer to -56 (which is what the exact signed area is)? And is there any other way to do it?

Why are you using Riemann sums when the question does not ask for it.
I always use the mid point rule for which the code isL

dx=4/100;
x=dx/2:dx:4;

ii=2-x.^3;
II=sum(transpose(ii))*dx

Otherwise type "help rsum" at the command line.

I don't see any point in your using a built in tool to do this, especialy as the graphics appear rather naff.

RonL

3. Well I feel like an idiot now . Sorry the following question was to do with Riemann sums and thats why I tried to do what I did (and fail pretty badly at that lol).

Thanks a lot, I got my answer (-57.2864 if you were wondering, I ended up using the right hand end point rule)!