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

6 次查看(过去 30 天)
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 个评论

请先登录,再进行评论。

采纳的回答

Alex Mcaulley
Alex Mcaulley 2019-6-7
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 个评论
Steven Brace
Steven Brace 2019-6-7
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!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by