Discussion:
Integration with experimental data
(too old to reply)
Bill
2011-03-26 21:56:04 UTC
Permalink
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?
Nasser M. Abbasi
2011-03-26 22:19:42 UTC
Permalink
Post by Bill
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
Yuji Zhang
2013-06-17 18:56:09 UTC
Permalink
trapz only gets the final velocity, or velocity at a particular time, right?

cumtrapz can give a v(t) curve.
Post by Nasser M. Abbasi
Post by Bill
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
Roger Stafford
2011-03-26 23:42:04 UTC
Permalink
Post by Bill
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
Ming Gui
2013-10-28 05:45:09 UTC
Permalink
Post by Roger Stafford
Post by Bill
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.
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.
Torsten
2013-10-28 07:35:14 UTC
Permalink
Post by Ming Gui
Post by Roger Stafford
Post by Bill
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.
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.
TideMan
2011-03-27 06:38:20 UTC
Permalink
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.
Bill
2011-03-27 20:49:05 UTC
Permalink
Post by TideMan
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.
TideMan
2011-03-27 23:47:18 UTC
Permalink
Post by TideMan
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.
Yuji Zhang
2013-06-17 19:10:13 UTC
Permalink
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~
Post by TideMan
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.
axh
2012-02-25 23:12:12 UTC
Permalink
Post by Bill
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.
Henry
2014-07-24 17:00:32 UTC
Permalink
Post by Bill
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?
Cumsum can work. But if you wanna rock it old school:

integrated_data(1) = data(1)/sample_rate; % initialize the integrated data set

for i = 2:length(data)
integrated_data(i) = data(i)/sample_rate + integrated_data(i-1); % does the integration
end

this is assuming a constant sampling rate and you have lots and lots of data points...
Continue reading on narkive:
Loading...