How do I calculate velocity with integration from acceleration data?

49 次查看(过去 30 天)
I am analyzing data from an accelerometer. I first calculated the magnitude and then I inserted a low pass filter. Then I took the integration of the data to get velocity and then again to get displacement. The result I got for my velocity doesn't seem right. There's peaks, but it's at a constant increase which doesn't make sense since the data is 5 consecutive jumps. Here is what I have in my code:
C = table2array(SampleJumpData2); %%Turning table data into matrix
y1 = SampleJumpData2(:,3); %% matrix and plot for y acceleration
y = table2array(y1);
x1 = SampleJumpData2(:,4); %% matrix and plot for x acceleration
x = table2array(x1);
z1 = SampleJumpData2(:,2); %% matrix and plot for x acceleration
z = table2array(z1);
time=C(:,1);
mag = sqrt(sum(x.^2 + y.^2 + z.^2, 2));
%%accelerations are integrated twice to produce displacements
xaccel = plot(time,mag);
xlabel('Time (sec)')
ylabel('Acceleration')
%%Design High Pass Filter
fs = 1000; % Sampling Rate
fc = 0.6; % Cut off Frequency
order = 2; % 6th Order Filter
%%Filter Acceleration Signals
[b1 a1] = butter(order,fc,'low');
accxf=filter(b1,a1,mag);
plot(time,accxf,'r'); hold on
plot(time,accxf)
xlabel('Time (sec)')
ylabel('Acceleration')
%%First Integration (Acceleration - Veloicty)
velocity=cumtrapz(time,accxf);
figure (3)
plot(time,velocity)
xlabel('Time (sec)')
ylabel('Velocity')
%%Filter Veloicty Signals
[b2 a2] = butter(order,fc,'low');
velf = filter(b2,a2,velocity);
%%Second Integration (Velocity - Displacement)
Displacement=cumtrapz(time, velf);
figure(4)
plot(time,Displacement)
xlabel('Time (sec)')
ylabel('Displacement ')

回答(1 个)

madhan ravi
madhan ravi 2018-11-18
  1 个评论
HN
HN 2020-5-4
What if someone wanted to use Rung Kutta to integrate tabular data of veloocity to get displacement ?
Thanks

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by