필터 지우기
필터 지우기

how to find distance between consecutive points

조회 수: 8 (최근 30일)
elisa ewin
elisa ewin 2017년 2월 2일
편집: Adam 2017년 2월 2일
Hi!
I have a matrix
A=[51.7365160000000 10.7978860000000;51.7366230000000 10.8319610000000;51.7389880000000 10.7849260000000;51.7424430000000 10.9195510000000;51.7443820000000 10.9157750000000;51.7448080000000 10.9160750000000;51.7523270000000 10.8756060000000;51.7525920000000 10.8758210000000;51.7526190000000 10.8738470000000;51.7526460000000 10.8763360000000;51.7528580000000 10.8477970000000;51.7530180000000 10.8776230000000];
The first column of A indicate latitude, the second column indicate longitude of differente points. I want to find the distance between consecutive points. I have used the function pdist in this way
a = pdist(A,'euclidean')';
but it gives the distance between all points and not only between consecutive point.
Can you help me to solve the problem?
thanks

채택된 답변

Adam
Adam 2017년 2월 2일
편집: Adam 2017년 2월 2일
sqrt( sum( abs( diff( A ) ).^2, 2 ) )
There may be a builtin function that does it to, but something so simple I tend to just do myself if I'm not aware of a builtin function off-hand.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by