Finding Distance Between Each Point (not the diagonal distance)

4 次查看(过去 30 天)
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