Central difference method or Diff for trajectories?
Mostrar comentarios más antiguos
Hello,
I have a dataset (2000 to 5000 sample size) of positions for (30 to 100) trajectories in 3D obtained from tracking particles in images with an exact known time step or frame rate. The problem when calculating the velocities of the particles is that of course if I use the "diff" function, the velocity array would have a smaller size than the positions, which is not what I want since I use both the velocities and positions in the same function to calculate another thermodynamic quanitity.
So I learned about the central difference method/gradient which gives a same-sized velocity array, the question is:
Is that correct to use it here? and which one since there's "gradient", "Dgradient" and "central diff". I don't know if that's relevant but the velocities should be normally distributed. I would also like to know if there's a preferred normality test for such data and sample size because most of the defined functions for the tests usually give different results.
I would really appreciate the help.
Thank you.
7 comentarios
Walter Roberson
el 10 de Sept. de 2021
Jan's DGradient in the File Exchange https://www.mathworks.com/matlabcentral/fileexchange/29887-dgradient is optimized and supports more methods. However it is not necessarily more accurate.
Mohamad Mossad
el 10 de Sept. de 2021
Walter Roberson
el 10 de Sept. de 2021
Not necessarily more accurate than gradient() when you use the (default) 1stOrder option.
I do not know anything about the mathematics of the 2ndOrder option.
Bjorn Gustavsson
el 10 de Sept. de 2021
If you are talking about trajectories for particles that are accelerated by some forces you might consider what your velocities are supposed to represent. Some high-accuracy numerical methods for integrating equations of motion use leapfrog-type schemes where the velocities are estimated at the "+1/2-timestep"s and not explicitly at the same time-steps of the positions. You might be interested in reading up on the Størmer-Verlet method.
Mohamad Mossad
el 10 de Sept. de 2021
Bjorn Gustavsson
el 10 de Sept. de 2021
(Since I work in auroral physics in Norway (which is what Størmer worked on and were from respectively) there is no way I will ever acknowledge the VV-algorithm named as such - but others might find me petty on this point). My idea was mainly that the velocities estimated with diff(r)/dt would naturally fit with an interpretation based on Størmer-Verlet-integration as the average velocity half-way between the different time-steps where you have the positions determined. You "just" have to remember to shift the v-estimates half a time-step forward. Exactly how it works on your experiment I have no idea - but I'm curious to see. Just go ahead and test!
Mohamad Mossad
el 10 de Sept. de 2021
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Filter Design and Analysis en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!