Velocity from X,Y,Z position coordinates

8 views (last 30 days)
melissa sandison
melissa sandison on 25 Jan 2021
Commented: Mathieu NOE on 25 Jan 2021
Hello,
I have tried to compute velcocity data from X,Y,Z position coordinate data. I additionally have the time each X,Y,Z sample was recorded at, so was able to work out the time step. I am hoping someone can tell me if what I have done is correct and also I am looking for advice on what to do next. I believe I should apply a butterworth filter but I am unsure how to do this.
data is F1 (3900,3), where F1(:,1) = X, F1(:,2) = Y , F1(:,3) = Z . Time between each z,yz recording is = dt
F1=Data(:,3:5); %select data
dt = Data(2,2); % time
for i = 1:length(F1)-1
f1_length(i) = sqrt((F1(i+1,1) - F1(i,1))^2 + (F1(i+1,2) - F1(i,2))^2 + ...
(F1(i+1,3) - F1(i,3))^2);
end
F1_velocity = f1_length/dt;
the above code works but not sure how to do filter. I have seen this online, but not sure why f_c = 4 . I think frequency would be my dt(?) but should I also divide by 2?
% low pass filter to extract envelope
f_c = 5; % cut-off frequency
[b, a] = butter(2, f_c./(freq/2), 'low'); % Butterworth LP filter
vel = filtfilt(b, a, vel); % zero-phase filtering (effective order = 4)
finally, I would like to calculate the "area" but not sure how to do this?
  3 Comments
melissa sandison
melissa sandison on 25 Jan 2021
Hello Mathieu,
Firstly, thank you so much for taking the time to help with my code. I really appreciate it.
I wen't through your code and I understand now how you have obtained velocity profile using forward/central/backward difference. This is most helpful!
Thank you also for the simple demo wav example, I know understand (and I read up on nyquist freq and also allaising).
Honestly, cant thank you enough! all the best!

Sign in to comment.

Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!