I have an acceleration data which is collected from a vehicle. I do also have a displacement measurement.

I would like to calcuate the displacement vector from the measured acceleration data, but no success yet.

Here is the data (the previous link was not working I updated the link): https://ufile.io/zyw3r

The measured acceleration data

The measured displacement data What I try:

filename = ('acc_time.csv'); 
accdata = csvread('acc_time.csv');

[mydata, myheader] = xlsread(filename); 
for i = 1:length(myheader)
      % compose a command to assign each column to a variable with the same 
      % name as the header
      commandExec = [myheader{i}, ' = ', 'mydata(:,', num2str(i) , ');'];
      % execute the composed command to actually create the variable
      evalin('base', commandExec ); 

vel_vector = cumtrapz(time,acc); 
disp_vector= cumtrapz(time,vel_vector);
plot(time, disp_vector)

and I get: Plot

but the displacement vector should be squiggy not like linear incremental.

Where am I wrong?

  • $\begingroup$ Doesn't look linear to me. Looks like a quadratic function to me. Squiggliness is very likely lost (correctly so) due to the low-pass behaviour of integration. $\endgroup$ – Marcus Müller Dec 14 '17 at 9:31
  • $\begingroup$ @MarcusMüller you are right it is more like a quadratic behaviour. But It should look like as the acceleration signal. How should I integrate over acceleration signal? $\endgroup$ – Yirmidokuz Dec 14 '17 at 10:00
  • $\begingroup$ No, it should not. That's what I'm saying. $\endgroup$ – Marcus Müller Dec 14 '17 at 10:06
  • $\begingroup$ @MarcusMüller but I do also have displacement data of the same acceleration signal, and the displacement data I calculate via matlab and the measured displacement data are not the same. $\endgroup$ – Yirmidokuz Dec 14 '17 at 11:16
  • $\begingroup$ @StanleyPawlukiewicz my velocity is a derivation with cumptraz. So it should not be taken into consideration. Only measured data is acceleration, I need to calculate the displacement from it, which should look like the acceleration data, should not have a linear trend. $\endgroup$ – Yirmidokuz Dec 15 '17 at 15:59

Generally, the observed effect occurs when there is an offset and/or linear drift present in your measured data. Double integration then leads to the quadratic (or higher order) effect observed in the data.

As @Stanley Pawlukiewicz states in his answer this can be due to the accelerometer registering gravity (not all accelerometers are capable of registering a constant acceleration field) but also due to temperature fluctuations, (electro)magnetic interference, strain at the base of the accelerometer, etc. Sometimes, it’s possible to “shield” your sensor for these effects but this can also be extremely challenging or expensive. In the latter case pre-processing your data can be an option too enable extracting meaningful results from your data.

The most straightforward approach to get rid of the quadratic drift in your double integrated acceleration signal is to detrend the data before integrating. If you substract the mean value before integrating the acceleration and velocity signals you should get reasonably “close” to the desired result (see matlab’s detrend function for other options).

Note that there also appears to be other noise and/or content in your measured acceleration signal; i.e. you will probably be able to get “close” to the desired result but will not get the exact same position signal. If that is critical you could use a more sophisticated signal processing approach or, if possible (and preferably) a better sensor (e.g. a position sensor).

  • $\begingroup$ Thanks for the useful explanation! Actually I would like to learn more about the subject/affair of that gravity registration of accelerometers. $\endgroup$ – Yirmidokuz Dec 16 '17 at 18:15
  • $\begingroup$ Google “MEMS accelerometer” or “DC response accelerometer” for a sensor type that can register gravity; google “ICP accelerometer” or “charge accelerometer” for (commonly used) sensor types that can not. Most manufacturers (e.g. PCB or Bruel&Kjaer) provide information on the working principles, common disturbance sources, calibration, etc. of their accelerometers. That should help you find what you’re searching for. $\endgroup$ – user883521 Dec 16 '17 at 18:45

Hi I have a similar problem, but I fixed by filtering the RAW acceleration data to remove noise, I use a fifth order butterworth filter and most of the problem was solved.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.