Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Integration with experimental data

Subject: Integration with experimental data

From: Bill

Date: 26 Mar, 2011 21:56:04

Message: 1 of 11

I have experimental acceleration data, A, and a corresponding time vector, t. I would like to integrate this data so I can obtain a position vs time graph.

How do I go about integrating this data without having a function? Is it correct to use cumtrapz?

i.e. will cumtrapz(t,A) provide me with velocity data?

Subject: Integration with experimental data

From: Nasser M. Abbasi

Date: 26 Mar, 2011 22:19:42

Message: 2 of 11

On 3/26/2011 2:56 PM, Bill wrote:
> I have experimental acceleration data, A, and a corresponding time vector, t. I would like to
> integrate this data so I can obtain a position vs time graph.
>
> How do I go about integrating this data without having a function? Is it correct to use cumtrapz?
>
> i.e. will cumtrapz(t,A) provide me with velocity data?

why not just use TRAPZ ?

--Nasser

Subject: Integration with experimental data

From: Roger Stafford

Date: 26 Mar, 2011 23:42:04

Message: 3 of 11

"Bill " <ringoranger@gmail.com> wrote in message <imlndk$8iu$1@fred.mathworks.com>...
> I have experimental acceleration data, A, and a corresponding time vector, t. I would like to integrate this data so I can obtain a position vs time graph.
>
> How do I go about integrating this data without having a function? Is it correct to use cumtrapz?
>
> i.e. will cumtrapz(t,A) provide me with velocity data?
- - - - - - - - -
  You could use 'cumtrapz' twice to obtain, first velocity, and then distance. However, such a technique is subject to rather serious cumulative error unless the time points are very closely-spaced.

  If your time steps are uniformly-spaced you could use the common fourth-order Runge–Kutta method sometimes known as RK4 to get fourth-order approximation. See:

 http://en.wikipedia.org/wiki/Runge–;Kutta_methods

Such techniques do assume that your data is comparatively free of noise.

  If your time-steps are not uniformly-spaced there also exist methods of obtaining higher order approximation, but I don't know off-hand the details on them.

  Matlab's various 'ode' routines for solving differential equations assume that the integrand data is given in terms of functions, not preassigned data points, so that presumably rules out their use your case.

Roger Stafford

Subject: Integration with experimental data

From: TideMan

Date: 27 Mar, 2011 06:38:20

Message: 4 of 11

On Mar 27, 10:56 am, "Bill " <ringoran...@gmail.com> wrote:
> I have experimental acceleration data, A, and a corresponding time vector, t.  I would like to integrate this data so I can obtain a position vs time graph.
>
> How do I go about integrating this data without having a function?  Is it correct to use cumtrapz?
>
> i.e. will cumtrapz(t,A) provide me with velocity data?

You need to high-pass filter to remove spurious low-frequency noise
from your signal, otherwise it gets amplified and will dominate the
result. Dealing with this is much more important than worrying about
whether you should use cumtrapz or whatever. In fact, I just use
cumsum.

I've found that orthogonal wavelet decomposition is the best high-pass
filter (if you have the wavelet toolbox), but there are others, like
Butterworth.

Subject: Integration with experimental data

From: Bill

Date: 27 Mar, 2011 20:49:05

Message: 5 of 11

TideMan <mulgor@gmail.com> wrote in message <215e3543-3fab-4e1b-9c81-2e92ba8a8834@b22g2000prb.googlegroups.com>...
> On Mar 27, 10:56 am, "Bill " <ringoran...@gmail.com> wrote:
> > I have experimental acceleration data, A, and a corresponding time vector, t.  I would like to integrate this data so I can obtain a position vs time graph.
> >
> > How do I go about integrating this data without having a function?  Is it correct to use cumtrapz?
> >
> > i.e. will cumtrapz(t,A) provide me with velocity data?
>
> You need to high-pass filter to remove spurious low-frequency noise
> from your signal, otherwise it gets amplified and will dominate the
> result. Dealing with this is much more important than worrying about
> whether you should use cumtrapz or whatever. In fact, I just use
> cumsum.
>
> I've found that orthogonal wavelet decomposition is the best high-pass
> filter (if you have the wavelet toolbox), but there are others, like
> Butterworth.

We are mainly concerned with low frequencies, so we have a buttersworth low-pass filter with a cutoff frequency of 100Hz. This cuts out quite a bit of the noise.

Our time data is equally spaced with each point being 0.0001 seconds after the last one. We have 30,000 data points (acceleration) at a sampling frequency of 10kHz, so we have 3 seconds of data.

Using trapz provides us with only one number, I don't really understand that. Using cumtrapz provides us with position, however the output isn't what we expected so it's hard for us to understand if the cumtrapz output is accurate.

Subject: Integration with experimental data

From: TideMan

Date: 27 Mar, 2011 23:47:18

Message: 6 of 11

On Mar 28, 9:49 am, "Bill " <ringoran...@gmail.com> wrote:
> TideMan <mul...@gmail.com> wrote in message <215e3543-3fab-4e1b-9c81-2e92ba8a8...@b22g2000prb.googlegroups.com>...
> > On Mar 27, 10:56 am, "Bill " <ringoran...@gmail.com> wrote:
> > > I have experimental acceleration data, A, and a corresponding time vector, t.  I would like to integrate this data so I can obtain a position vs time graph.
>
> > > How do I go about integrating this data without having a function?  Is it correct to use cumtrapz?
>
> > > i.e. will cumtrapz(t,A) provide me with velocity data?
>
> > You need to high-pass filter to remove spurious low-frequency noise
> > from your signal, otherwise it gets amplified and will dominate the
> > result.  Dealing with this is much more important than worrying about
> > whether you should use cumtrapz or whatever.  In fact, I just use
> > cumsum.
>
> > I've found that orthogonal wavelet decomposition is the best high-pass
> > filter (if you have the wavelet toolbox), but there are others, like
> > Butterworth.
>
> We are mainly concerned with low frequencies, so we have a buttersworth low-pass filter with a cutoff frequency of 100Hz.  This cuts out quite a bit of the noise.
>
> Our time data is equally spaced with each point being 0.0001 seconds after the last one.  We have 30,000 data points (acceleration) at a sampling frequency of 10kHz, so we have 3 seconds of data.
>
> Using trapz provides us with only one number, I don't really understand that.  Using cumtrapz provides us with position, however the output isn't what we expected so it's hard for us to understand if the cumtrapz output is accurate.

You've got it arse about face.
For integration, you need to high-pass filter.
Consider y=cos(wt)
it integrates to 1/w sin(wt)
and integrates again to -1/w^2 cos(wt)
which is -y/w^2
So, if w is small, the acceleration gets scaled up by much more than
if w is large.
Therefore, any low frequency noise in the signal gets amplified.
This results in the displacement derived from double integration of
the acceleration wandering all over the place and perhaps heading off
to + or - infinity.
Perhaps this is why "the output isn't what we expected".
IMHO it has nothing to do with cumtrapz, which works fine, just as
cumsum would.

Subject: Integration with experimental data

From: axh

Date: 25 Feb, 2012 23:12:12

Message: 7 of 11

"Bill " <ringoranger@gmail.com> wrote in message <imlndk$8iu$1@fred.mathworks.com>...
> I have experimental acceleration data, A, and a corresponding time vector, t. I would like to integrate this data so I can obtain a position vs time graph.
>
> How do I go about integrating this data without having a function? Is it correct to use cumtrapz?
>
> i.e. will cumtrapz(t,A) provide me with velocity data?

You can find a empirical model with Tablecurve, or other similar software, that fit your experimental data (Error=0). You can use this model on matlab to run a ODE solver (function to integrate differential equations).

Trapeze system can give you a rough idea of ??the required result, but the error is biger.

Subject: Integration with experimental data

From: Yuji Zhang

Date: 17 Jun, 2013 18:56:09

Message: 8 of 11

trapz only gets the final velocity, or velocity at a particular time, right?

cumtrapz can give a v(t) curve.
 

"Nasser M. Abbasi" wrote in message <imloq4$6nu$1@speranza.aioe.org>...
> On 3/26/2011 2:56 PM, Bill wrote:
> > I have experimental acceleration data, A, and a corresponding time vector, t. I would like to
> > integrate this data so I can obtain a position vs time graph.
> >
> > How do I go about integrating this data without having a function? Is it correct to use cumtrapz?
> >
> > i.e. will cumtrapz(t,A) provide me with velocity data?
>
> why not just use TRAPZ ?
>
> --Nasser

Subject: Integration with experimental data

From: Yuji Zhang

Date: 17 Jun, 2013 19:10:13

Message: 9 of 11

Nice explaination! Thanks tideman!

Is there a book or something where I can read about details of this issue - like quantitative implementation? Any recommendation is appreciated. Thanks everyone~


TideMan <mulgor@gmail.com> wrote in message <3bbe487c-22a8-4e9a-9c65-94200a9aadc1@18g2000prd.googlegroups.com>...

> You've got it arse about face.
> For integration, you need to high-pass filter.
> Consider y=cos(wt)
> it integrates to 1/w sin(wt)
> and integrates again to -1/w^2 cos(wt)
> which is -y/w^2
> So, if w is small, the acceleration gets scaled up by much more than
> if w is large.
> Therefore, any low frequency noise in the signal gets amplified.
> This results in the displacement derived from double integration of
> the acceleration wandering all over the place and perhaps heading off
> to + or - infinity.
> Perhaps this is why "the output isn't what we expected".
> IMHO it has nothing to do with cumtrapz, which works fine, just as
> cumsum would.
>

Subject: Integration with experimental data

From: Ming Gui

Date: 28 Oct, 2013 05:45:09

Message: 10 of 11

"Roger Stafford" wrote in message <imltkc$ar6$1@fred.mathworks.com>...
> "Bill " <ringoranger@gmail.com> wrote in message <imlndk$8iu$1@fred.mathworks.com>...
> > I have experimental acceleration data, A, and a corresponding time vector, t. I would like to integrate this data so I can obtain a position vs time graph.
> >
> > How do I go about integrating this data without having a function? Is it correct to use cumtrapz?
> >
> > i.e. will cumtrapz(t,A) provide me with velocity data?
> - - - - - - - - -
> You could use 'cumtrapz' twice to obtain, first velocity, and then distance. However, such a technique is subject to rather serious cumulative error unless the time points are very closely-spaced.
>
> If your time steps are uniformly-spaced you could use the common fourth-order Runge–Kutta method sometimes known as RK4 to get fourth-order approximation. See:
>
> http://en.wikipedia.org/wiki/Runge–;Kutta_methods
>
> Such techniques do assume that your data is comparatively free of noise.
>
> If your time-steps are not uniformly-spaced there also exist methods of obtaining higher order approximation, but I don't know off-hand the details on them.
>
> Matlab's various 'ode' routines for solving differential equations assume that the integrand data is given in terms of functions, not preassigned data points, so that presumably rules out their use your case.
>
> Roger Stafford




Hi Roger,

How do you do integration by Runge Kutta Method without having the initial condition?
I had a set of acceleration data without the initial condition and I wish to integrate them into displacement. Any idea?

Thank you.

Subject: Integration with experimental data

From: Torsten

Date: 28 Oct, 2013 07:35:14

Message: 11 of 11

"Ming Gui" wrote in message <l4ktl5$sb9$1@newscl01ah.mathworks.com>...
> "Roger Stafford" wrote in message <imltkc$ar6$1@fred.mathworks.com>...
> > "Bill " <ringoranger@gmail.com> wrote in message <imlndk$8iu$1@fred.mathworks.com>...
> > > I have experimental acceleration data, A, and a corresponding time vector, t. I would like to integrate this data so I can obtain a position vs time graph.
> > >
> > > How do I go about integrating this data without having a function? Is it correct to use cumtrapz?
> > >
> > > i.e. will cumtrapz(t,A) provide me with velocity data?
> > - - - - - - - - -
> > You could use 'cumtrapz' twice to obtain, first velocity, and then distance. However, such a technique is subject to rather serious cumulative error unless the time points are very closely-spaced.
> >
> > If your time steps are uniformly-spaced you could use the common fourth-order Runge–Kutta method sometimes known as RK4 to get fourth-order approximation. See:
> >
> > http://en.wikipedia.org/wiki/Runge–;Kutta_methods
> >
> > Such techniques do assume that your data is comparatively free of noise.
> >
> > If your time-steps are not uniformly-spaced there also exist methods of obtaining higher order approximation, but I don't know off-hand the details on them.
> >
> > Matlab's various 'ode' routines for solving differential equations assume that the integrand data is given in terms of functions, not preassigned data points, so that presumably rules out their use your case.
> >
> > Roger Stafford
>
>
>
>
> Hi Roger,
>
> How do you do integration by Runge Kutta Method without having the initial condition?
> I had a set of acceleration data without the initial condition and I wish to integrate them into displacement. Any idea?
>
> Thank you.

Google for
matlab & integration of displacement data
and check the hits.

Best wishes
Torsten.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us