Effacer les filtres
Effacer les filtres

Finding Distance Between Each Point (not the diagonal distance)

4 vues (au cours des 30 derniers jours)
Erkin Karatas
Erkin Karatas le 27 Déc 2019
Réponse apportée : Matt J le 27 Déc 2019
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.

Réponse acceptée

Matt J
Matt J le 27 Déc 2019
x=XY(:,1); y=XY(:,2);
result=abs(x-x.')+abs(y-y.');

Plus de réponses (1)

Matt J
Matt J le 27 Déc 2019
result=pdist2(XY,XY,'cityblock')

Catégories

En savoir plus sur Computational Geometry dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by