For Loop for finding distance between 9 centroids
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I would like to find the distance between 9 data points in a neat way.
I tried to do it in a for loop but that didn't work out.
Any help is appreciated.
An example of what I'm trying to do is given below:
A = [5,2];
B = [3,2];
C = [4,5];
D = [6,9];
E = [7,7];
F = [3,2];
G = [9,8];
H = [1.5,1.7];
I = [2.5,3.2];
X = [A;B];
Y = [A;C];
Z = [B;C];
.
.
.
pdist(X);
pdist(Y);
pdist(Z);
.
.
.
It should tell me the distance between any of these data points.
I'm trying to find the smallest distance between any of these variables.
(To be excluded: A vs A, B vs B etc.) (To be included: A vs all, B vs all etc.)
0 Commenti
Risposte (1)
Image Analyst
il 31 Mar 2017
Try pdist2:
distances = pdist2(xy, xy);
where xy is an N by 2 list of x,y coordinates.
0 Commenti
Vedere anche
Categorie
Scopri di più su Dimensionality Reduction and Feature Extraction in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!