Computing displacement from accelerometer data

조회 수: 30 (최근 30일)
Paul Heineman
Paul Heineman 2022년 9월 27일
댓글: Cris LaPierre 2022년 9월 27일
Hi,
I am trying to convert my accelerometer data to displacement data through integrating twice, I looked at other questions here and similar questions have been asked and answered however I still dont get a satisfactory answer.
Te problem I have is that I get a displacement of 5*10^-3 which does not make sense from the experiment. I have attached my data for reference.
I import the data from excel, detrend it and then use the function cumtrapz twice.
data = readmatrix('https://de.mathworks.com/matlabcentral/answers/uploaded_files/1138190/Acceleration%20without%20g%202022-09-07%2009-49-36.xls');
%Acceleration data
acc = data(:,4); % Add gravity factor ( g to m/s²)
%acc = flip(acc);
acc = detrend(acc); % baseline correction
%Time
tStep = 20/length(acc);
N = length(acc)*tStep;
t = 0:tStep:N;
t(end) = [];
N = length(t);
dt = mean(diff(t));
fs = 1/dt;
% High pass filter
N = 2;
fc = 2;
[B,A] = butter(N,2*fc/fs,'high');
acc2 = filter(B,A,acc);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
velocity = cumtrapz(dt,acc2);
velocity = detrend(velocity); % baseline correction
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp = cumtrapz(dt,velocity);
%disp = detrend(disp); % baseline correction
%
figure(1)
%plot(t,acc);
hold on;
%plot(t,velocity);
hold on;
plot(t,disp);
title('disp'); ylabel('m');xlabel('time (s)');
I am wondering what I do wrong, thanks in advance

채택된 답변

Cris LaPierre
Cris LaPierre 2022년 9월 27일
편집: Cris LaPierre 2022년 9월 27일
I think the first issue is to find the magnitude of the acceleration vector using the data from all 3 axes. From there, you can use cumtrapz with the Time and acceleration data, then Time and the resulting velocity to get position.
file = "https://www.mathworks.com/matlabcentral/answers/uploaded_files/1138190/Acceleration%20without%20g%202022-09-07%2009-49-36.xls";
data = readtable(file);
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
data.Properties.VariableNames = ["Time","X","Y","Z","Abs"];
% Combined acceleration
accel = sqrt(data.X.^2 + data.Y.^2 + data.Z.^2);
figure
plot(data.Time,accel)
v = cumtrapz(data.Time,accel);
x = cumtrapz(data.Time,v);
figure
plot(data.Time,v)
figure
plot(data.Time,x)
  댓글 수: 2
Paul Heineman
Paul Heineman 2022년 9월 27일
편집: Paul Heineman 2022년 9월 27일
Thank you for your quick answer chris, however I think I should have been more carefull stating my question. The experiment was a cantilever beam oscilating in the z direction, and the displacement should be around the x axis in the graph. The result would mean that all three graphs look similar, I expect a displacement between 1 and 10 centimeter in positive and negative direction (z -axis from the data).
Cris LaPierre
Cris LaPierre 2022년 9월 27일
We would need to know the initial conditions. Perhaps most relevant here would be what the initial displacement of the cantilever beam was, as your data starts with max acceleration in Z

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Directed Graphs에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by