Calculating distance from a refence vector for a matrix
Afficher commentaires plus anciens
I have a matrix A and a reference vector ref I want to calculate the distance for each row of the matrix.
Example:
A = [1 2 3; 4 5 6; 7 8 9];
ref = [2 6 8];
distance = sqrt(sum((A(1,:) - ref) .^ 2));
How to do this for all the rows of A in a single line ?
Réponse acceptée
Plus de réponses (0)
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!