Calculating Normalized Jerk in a signal?

32 visualizaciones (últimos 30 días)
FsC
FsC el 3 de Mayo de 2023
Comentada: Jak el 17 de Jul. de 2023
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 comentario
Mathieu NOE
Mathieu NOE el 4 de Mayo de 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

Iniciar sesión para comentar.

Respuesta aceptada

Zuber
Zuber el 9 de Mayo de 2023
Hi,
I understand that you want to implement the specified equation in MATLAB for calculating normalized jerk. Let the signal (1xN array) which represents position as a function of time denoted by ‘s’. The ‘diff’ function can be used to calculate the jerk as follows: -
freq = 60 % sampling frequency
dt = 1/freq; % time interval between samples
first_der = diff(s)/dt % first derivative of signal ‘s’
sec_der = diff(first_der)/dt % second derivative of signal 's’
jerk = diff(sec_der)/dt % third derivative of signal ‘s’
Further, the integral can be evaluated using ‘trapz’ function. Overall, the equation can be implemented in MATLAB as follows:-
integrand = dt * jerk.^2;
nj = sqrt(0.5 * trapz(integrand) * (StrokeDuration^5 / StrokeLength^2));
For more information on ‘trapz’ and ‘diff’ functions, please refer to the following documentation links:-
  1. https://www.mathworks.com/help/matlab/ref/trapz.html
  2. https://www.mathworks.com/help/matlab/ref/diff.html
I hope it resolves your query.
  2 comentarios
FsC
FsC el 9 de Mayo de 2023
amazing! Thank you!
Jak
Jak el 17 de Jul. de 2023
Hi, how did you account for the (t) in dt jerk^2 (t)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by