How to calculate maximum distance between two points (coordinates) on a XY (2D) plane ?

조회 수: 9 (최근 30일)
I am plotting two vectors (x and y), i.e. plot x vs. y.
I want to calculate distance between points which are furthest away from each other. I also need their indices to reference a time stamp.
Using pdist2 I get the pink line, but the black line (annotation) seem to be the actual largest distance.

채택된 답변

Voss
Voss 2024년 4월 30일
"seem to be the largest distance"
Seems to be, but it's not. The x-scale and y-scale are not quite the same. Use
axis equal
to view the plot with a 1:1 aspect ratio. When you do that, I bet you'll see that the greatest distance given by pdist2 is correct.
  댓글 수: 3
Viraj Sabane
Viraj Sabane 2024년 4월 30일
This makes sense. Thanks for providing an example, it makes it amply clear.
It is a very useful insight.
Cheers,
Viraj

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by