Displacement from accelerometer data
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Dear everyone,
I am trying to integrate data from accelerometer measurements to determine velocity and displacement of the system. The velocity looks ok, for which i consider the following approach
acceleration = [nx1]; % Data from accelerometer
dt = [1x1]; % Length of each time-step
velocity = cumtrapz(dt,acceleration);
However, when I try to utilize the same approach once again in the aim of determining displacement of the system i get unrealistic displacements. The following code is considered
displacement = cumtrapz(dt,velocity);
I have also tried other resources and functions available on matlab community, however, no progress yet.

채택된 답변
Mathieu NOE
2021년 4월 22일
1 개 추천
hello
the drift in the displacement is due to the fact that the velocity itself is not a zero mean signal
so if you are interested in the dynamic signal only , before each integration with cumtrapz you have to detrend your input data
help detrend
detrend Remove a polynomial trend.
Y = detrend(X) removes the best straight-line fit linear trend from the data in vector X and returns the residual in vector Y. If X is a matrix, detrend removes the trend from each column of the matrix.
댓글 수: 10
Derek Cooper
2021년 4월 22일
편집: Derek Cooper
2021년 4월 22일
Unfortunately it doesnt look corret after detrending too

Mathieu NOE
2021년 4월 22일
you shoud add some high pass filtering , to remove that large bump
Derek Cooper
2021년 4월 27일
Still not working
Mathieu NOE
2021년 4월 27일
hi
what do you get ? why "stil not working" ? what do you expect as result ?
can you share your code ?
tx
Hello,
Thanks for your response. I am expecting an exponential decay of the displacmenet. Here comes my code and attached is the acceleration data. The initial displacmement is around 200 [mm].
load('Acceleration.mat');
% Acceleration data
acc = acc*9.81; % Add gravity effect
acc = detrend(acc)
% Time
tStep = 0.00048828 % Length of each time step
N = length(acc)*tStep;
t = 0:tStep:N;
t(end) = [];
N = length(t);
dt = median(diff(t)); % Average dt
fs = 1/dt; % Frequency [Hz] or sampling rate
%
velocity = cumtrapz(dt,acc);
velocity = detrend(velocity);
disp = cumtrapz(dt,velocity);
disp = detrend(disp);
%
figure
plot(velocity);
figure
plot(disp);
here you are , as I suggested , use a bit of high pass filtering in conjunction with detrend
clc
clearvars
load('Acceleration.mat');
% Acceleration data
acc = acc*9.81; % Add gravity effect
acc = detrend(acc);
% Time
tStep = 0.00048828; % Length of each time step
N = length(acc)*tStep;
t = 0:tStep:N;
t(end) = [];
N = length(t);
dt = mean(diff(t)); % Average dt
fs = 1/dt; % Frequency [Hz] or sampling rate
% some additionnal high pass filtering
N = 2;
fc = 0.5; % Hz
[B,A] = butter(N,2*fc/fs,'high');
acc2 = filter(B,A,acc);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
velocity = cumtrapz(dt,acc2);
velocity = detrend(velocity);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp = cumtrapz(dt,velocity);
%
figure(1)
plot(t,acc);
figure(2)
plot(t,velocity);
figure(3)
plot(t,disp);
We put accelerometers on ice skaters doing their jumps. If we double-integrated the signal, without highpass filtering or detrending, the doubly-integrated signal put them mny miles away by the end of their practice! We observed similar results when measuring cranium acceleration of soccer players doing headers.
Oskar Kilgus
2023년 6월 28일
I´m analyzing accelerometer data too and i am wondering if i detrend acceleration aswell as velocity or just acceleration. Looking at the plots, both outcomes look okay to me considering the underlying system.
Thanks in advance.
Mathieu NOE
2023년 6월 28일
it depends of your signal quality and fft spectrum
if you have a loft of drift / ofset and very low frequency noise , then you may need more filtering
with very clean data , you may have to use only detrend but every situation is a special case
William Rose
2023년 6월 28일
A good general principle is to avoid detrending and filtering of your raw data as much as possible, so that you preserve the information in the data. Detrend and filter only to the extent that it is required to get reasonable looking results. Even then, consider whether the required detrending and filtering indicates some probelm with the instrumentaiton which you could correct in future experiments. It is not surprising that accelerometer signals need detrending, since even small offsets will grow parabolically when integrated twice. And for this reason, fitting a quadratic to the full length acceleration signal is a reasonable next step, if linear detrending seems to be insufficient.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
