standard euclidean distance, matlab
Afficher commentaires plus anciens
Helllo
I need help with standard euclidean distance, knew would someone help with matlab code ?
I can not use, matlab function, pdist, pdist2.
I need standard euclidean distance between two vectors.
Thanks.
Réponses (1)
Walter Roberson
le 5 Fév 2014
sqrt(sum((v1 - v2).^2))
6 commentaires
Tomas
le 5 Fév 2014
Walter Roberson
le 5 Fév 2014
"Standardized Euclidean distance" perhaps? As described in http://www.mathworks.com/help/stats/pdist.html ?
Tomas
le 5 Fév 2014
Walter Roberson
le 5 Fév 2014
Modifié(e) : Walter Roberson
le 5 Fév 2014
sqrt(sum((v1./nanstd(v1) - v2./nanstd(v2)).^2))
However this formula assumes v1 and v2 are vectors. If they need to be arrays, I would need to change the code.
Tomas
le 5 Fév 2014
Walter Roberson
le 6 Fév 2014
sqrt(sum((A1 ./ repmat(nanstd(A1), size(A1,1), 1) - A2 ./ repmat(nanstd(A2), size(A2,1), 1)).^2, 2))
This would be for taking the distance for the rows of A1 to the corresponding rows of A2.
I am thinking that possibly it should be different, like this:
sqrt(sum(((A1-A2) ./ repmat( nanstd([A1;A2]), size(A1,1), 1)).^2,2))
Catégories
En savoir plus sur Creating and Concatenating Matrices 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!