Effacer les filtres
Effacer les filtres

How to calculate total distance traveled from position vs time experimental data

6 vues (au cours des 30 derniers jours)
I have some experimental data like this (position against time), how do i find the scalar value of distance moved?
This should be 10+16+16+14=56m.* fixed dumb error
Not interested in direction just magnitude of movement.
Thanks!
  3 commentaires
Steven Brace
Steven Brace le 7 Juin 2019
Doh, looks like i need to go back to school! Yeh thats what I meant to type!

Connectez-vous pour commenter.

Réponse acceptée

Alex Mcaulley
Alex Mcaulley le 7 Juin 2019
Following your image, you have a position array like:
position = [10,10,0,0,-16,-16,0,14];
Then to calculate the total distance:
distance = sum(abs(diff(position)))
  1 commentaire
Steven Brace
Steven Brace le 7 Juin 2019
Nice, I did think this would proabbly be the solution, but thought I would have to use a loop to do it, bu nice to see it can be done in one line!
Thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by