How do I calculate velocity with integration from acceleration data?

49 ビュー (過去 30 日間)
Kelsey Vukas
Kelsey Vukas 2018 年 11 月 18 日
コメント済み: HN 2020 年 5 月 4 日
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 Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by