Displacement from accelerometer data
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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 日
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
Derek Cooper
2021 年 4 月 27 日
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);
Mathieu NOE
2021 年 4 月 27 日
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);
William Rose
2022 年 4 月 7 日
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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
