Integration of numerical data

563 views Asked by At

I'm writing a test tomorrow and I'm contemplating doing everything on Matlab, to save time.

Some questions require numerical integration of datapoints (points, not necessarily functions).

E.g.

C=[0 1 5 8 10 8 6 4 3 2.2 1.5 0.6 0];

I've used trapz(C) to determine the integral of the data (area under the curve) and compared that to what my textbook gets. Often, there is too large a difference between the two.

Is there another easy and fast way that the above data can be integrated numerically using Matlab, e.g. by using Simpson's rule, Gauleg or spline?

I've taken a look at integrate(), but that seems to work only on functions?

1

There are 1 answers

2
anon01 On

Are your data points spaced by dx = 1? if dx is .5 for example, this would change the result by a factor of two.

Otherwise, I'd point out: the data point by themselves, assuming zero width, will produce an area of 0: the point being that your textbook must be assuming some kind of interpolation between them to get a meaningful integral. If they are straight line segements, trapz(C) should give you the correct result; if your textbook is doing something else (points taken from a smooth function, for example), it is not surprising the results would be different.