Distance between points in a graph
Afficher commentaires plus anciens
I have plotted a graph which has 5 points. Is there any in built feature in Matlab which can help me calculate the distance between each point? Any help is appreciated, Thank you :)
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 23 Jan 2022
0 votes
pdist() can be configured with a number of different distance metrics.
However, I have to wonder if you are assuming that the 5 points are on a curve, and if you want the distance along the curve. If so then we would need to know what model you are using for the curve joining the points.
2 commentaires
Varun Shrishail Soraganvi
le 23 Jan 2022
Modifié(e) : Varun Shrishail Soraganvi
le 23 Jan 2022
Walter Roberson
le 24 Jan 2022
Modifié(e) : Walter Roberson
le 24 Jan 2022
You asked for "distance", but you did not specify how distance was to be calculated
xy = rand(5, 2); % Sample points.
distances_cheb = squareform(pdist(xy, 'chebychev'))
distances_city = squareform(pdist(xy, 'cityblock'))
distances_euc = squareform(pdist(xy, 'euclidean'))
distances_ma = squareform(pdist(xy, 'mahalanobis'))
distances_mi = squareform(pdist(xy, 'minkowski', 3))
... and others
Catégories
En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!