How do I calculate velocity with integration from acceleration data?
Afficher commentaires plus anciens
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 ')
Réponses (1)
madhan ravi
le 18 Nov 2018
velocity=cumtrapz(time,acceleration)
1 commentaire
HN
le 4 Mai 2020
What if someone wanted to use Rung Kutta to integrate tabular data of veloocity to get displacement ?
Thanks
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!