Clear Filters
Clear Filters

Displacement from acceleration measurements

3 views (last 30 days)
M
M on 23 Mar 2023
Answered: Star Strider on 25 Mar 2023
I have the attached acceleretion measurements and I have used the following code to get the displacement. I suspected to get the displacement curve having multiple cycles, why I got only one cycle (It must contain multiple cycles)?
Any suggestions?
data = dlmread("test4.txt"); x = data(:, 1);
acc1 = detrend(x,'linear');
Fs = 1000 ; % Sampling frequency Ts = 1/Fs ; % Sampling period L = length (acc1) ; % Length of signal t = 0:Ts:(Ts*L)-Ts; dt = mean(diff(t)); % Average dt %fs = 1/dt; % Frequency [Hz] or sampling rate
% some additionnal high pass filtering %N = 4; %fc = 0.05; % Hz %[B,A] = butter(N,2*fc/Fs,'high'); %%acc2 = filter(B,A,acc); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
velocity1 = cumtrapz(dt,acc1); velocity1 = detrend(velocity1,'linear'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% disp1 = cumtrapz(dt,velocity1);
figure(1) subplot(311),plot(t,acc1); subplot(312),plot(t,velocity1); subplot(313),plot(t,disp1);

Answers (1)

Star Strider
Star Strider on 25 Mar 2023
The slopes are due to a constant that is being integrated can be removed by subtracting the mean of the variable to be integrated (thus removing any trends due to the integration), and then calling cumtrapz to do the integration.
No further signal processing is necessary —
A = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1334739/test4.txt');
A = fillmissing(A,'linear');
Fs = 1000;
L = size(A,1);
t = linspace(0, L-1, L).'/Fs;
V = cumtrapz(t, A-mean(A));
D = cumtrapz(t, V-mean(V));
figure
tiledlayout(size(A,2),3)
for k = 1:size(A,2)
nexttile
plot(t, A(:,k))
grid
ylim([-0.5 2.5])
ylabel('Acceleration')
xlabel('Time')
title("Column "+k)
nexttile
plot(t, V(:,k))
grid
ylim([-0.02 0.02])
ylabel('Velocity')
xlabel('Time')
nexttile
plot(t, D(:,k))
grid
ylim([-10 30]*1E-4)
ylabel('Displacement')
xlabel('Time')
end
I used ylim to force all the y-axis ranges to be the same, relative to each integration. This may make them a bit easier to interpret.
.

Categories

Find more on Biological and Health Sciences in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!