필터 지우기
필터 지우기

Finding Distance Between Each Point (not the diagonal distance)

조회 수: 4 (최근 30일)
Erkin Karatas
Erkin Karatas 2019년 12월 27일
답변: Matt J 2019년 12월 27일
Hi all, I am trying to calculate distance between 50 points. The coordinates of the points are given in the coordinates.xlsx excel file. 1st column is the X coordinate and the 2nd column is Y coordinate. I want to create a 50x50 matrix which shows distances between those points, but I cannot move diagonally. I can only move in X and Y coordinates to calculate distance.

채택된 답변

Matt J
Matt J 2019년 12월 27일
x=XY(:,1); y=XY(:,2);
result=abs(x-x.')+abs(y-y.');

추가 답변 (1개)

Matt J
Matt J 2019년 12월 27일
result=pdist2(XY,XY,'cityblock')

카테고리

Help CenterFile Exchange에서 Computational Geometry에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by