From: Marcio Barbalho on
Hello dear friends...

I would to know if you know any other numerical integration method besides 'trapz' given x an y vectors:

Area = trapz(x,y)

my data are kind of randomic and I have obtained areas that are not so precise, numbers are not matching...So I was wondering if you could give some help on increasing the performance of matlab's numerical integrators.

Many thanks
From: us on
"Marcio Barbalho" <marciobarbalho(a)live.com> wrote in message <hu9gb8$dvg$1(a)fred.mathworks.com>...
> Hello dear friends...
>
> I would to know if you know any other numerical integration method besides 'trapz' given x an y vectors:
>
> Area = trapz(x,y)
>
> my data are kind of randomic and I have obtained areas that are not so precise, numbers are not matching...So I was wondering if you could give some help on increasing the performance of matlab's numerical integrators.
>
> Many thanks

well...
not even ML has the magic wand that turns your bad data into good data...
unless, of course, you use one of its many powerful interpolators - which, however, will make things even worse...

us
From: Roger Stafford on
"Marcio Barbalho" <marciobarbalho(a)live.com> wrote in message <hu9gb8$dvg$1(a)fred.mathworks.com>...
> Hello dear friends...
>
> I would to know if you know any other numerical integration method besides 'trapz' given x an y vectors:
>
> Area = trapz(x,y)
>
> my data are kind of randomic and I have obtained areas that are not so precise, numbers are not matching...So I was wondering if you could give some help on increasing the performance of matlab's numerical integrators.
>
> Many thanks

It all depends on what you mean by "randomic". As Urs says, there is no magic wand to make good data out of bad. If your data is bad because it is noisy, then trapz results are about as good as you are going to get.

On the other hand if your data is comparatively free of noise and is accurately obtained from a function which is smoothly varying, meaning that it's higher derivatives are not excessively large, then there is hope for better accuracy from higher order integration methods.

There are a number of these in the file exchange, including one I wrote which does cubic type approximation, but they all require that the discrete data be derived from smooth functions. Mine approximates the integral over each interval using the two endpoints of the interval and two other points at the ends of the two adjacent intervals. It computes the integral a cubic polynomial would have over the central interval if it runs through all four points. However the size of the inevitable error it makes depends on how large the underlying function's fourth derivative is, based on the mean value theorem of calculus. For trapz the mean value theorem expresses the error in terms of its second derivative.

Roger Stafford
From: Marcio Barbalho on
"us " <us(a)neurol.unizh.ch> wrote

> well...
> not even ML has the magic wand that turns your bad data into good data...
> unless, of course, you use one of its many powerful interpolators - which, however, will make things even worse...
>

No, that was not my point. I can't change the data, nor should I. What I am trying to find is an alternative integrator to 'trapz'.

Many thanks
From: us on
"Marcio Barbalho" <marciobarbalho(a)live.com> wrote in message <hu9mfj$rhl$1(a)fred.mathworks.com>...
> "us " <us(a)neurol.unizh.ch> wrote
>
> > well...
> > not even ML has the magic wand that turns your bad data into good data...
> > unless, of course, you use one of its many powerful interpolators - which, however, will make things even worse...
> >
>
> No, that was not my point. I can't change the data, nor should I. What I am trying to find is an alternative integrator to 'trapz'.
>
> Many thanks

i guess you missed my point a bit:
whichever integrator you're using, it will have to deal with your data, which, as you said yourself, is messy...
hence, as john d'errico usually says at this point: garbage in, garbage out... no matter what box is in between...

however, there are many other ML integrators available, see roger stafford's reply...

us