Calculating Normalized Jerk in a signal?
Show older comments
Hello,
I am trying to calculate the normalized jerk of a signal using a specific formula but am unsure how to implement it using MATLAB.
I have a signal (1x N array of positive values) that changes position across time (sampling frequency is 60 Hz). From this I am trying to calculate the normalized jerk using the following equation:
where jerk is the third derivative of the position as a function of time, stroke duration is the total time the stroke takes from strart to finish and stroke length is the total distance of the stroke from start to finish (in this case Euclidean Distance)
I am especially confused on how to implement the integral and jerk components of the equation.
Do you know how to implement the equation in MATLAB?
1 Comment
Mathieu NOE
on 4 May 2023
hello
have you started a code ? where is the biggest hurdle ?
to differentiate a signal you can use either diff , gradient or the function firstsecondderivatives code provided below
to do the integral you can use trapz
read the doc and you should be able to putthe puzzle together
function [dy, ddy] = firstsecondderivatives(x,y)
% The function calculates the first & second derivative of a function that is given by a set
% of points. The first derivatives at the first and last points are calculated by
% the 3 point forward and 3 point backward finite difference scheme respectively.
% The first derivatives at all the other points are calculated by the 2 point
% central approach.
% The second derivatives at the first and last points are calculated by
% the 4 point forward and 4 point backward finite difference scheme respectively.
% The second derivatives at all the other points are calculated by the 3 point
% central approach.
n = length (x);
dy = zeros;
ddy = zeros;
% Input variables:
% x: vector with the x the data points.
% y: vector with the f(x) data points.
% Output variable:
% dy: Vector with first derivative at each point.
% ddy: Vector with second derivative at each point.
dy(1) = (-3*y(1) + 4*y(2) - y(3)) / (2*(x(2) - x(1))); % First derivative
ddy(1) = (2*y(1) - 5*y(2) + 4*y(3) - y(4)) / (x(2) - x(1))^2; % Second derivative
for i = 2:n-1
dy(i) = (y(i+1) - y(i-1)) / (x(i+1) - x(i-1));
ddy(i) = (y(i-1) - 2*y(i) + y(i+1)) / (x(i-1) - x(i))^2;
end
dy(n) = (y(n-2) - 4*y(n-1) + 3*y(n)) / (2*(x(n) - x(n-1)));
ddy(n) = (-y(n-3) + 4*y(n-2) - 5*y(n-1) + 2*y(n)) / (x(n) - x(n-1))^2;
end
Accepted Answer
More Answers (0)
Categories
Find more on Numerical Integration and Differentiation 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!