필터 지우기
필터 지우기

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
Steven Brace
Steven Brace 2019년 6월 7일
Doh, looks like i need to go back to school! Yeh thats what I meant to type!

댓글을 달려면 로그인하십시오.

채택된 답변

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