Borrar filtros
Borrar filtros

Checking every norm of a row in a matrix with all other rows.

2 visualizaciones (últimos 30 días)
gamer
gamer el 12 de Jun. de 2021
Comentada: gamer el 12 de Jun. de 2021
Hello community,
I have another question. It would be really nice if you could help me:)
So I ve got a nx2 matrix.
p=[r + (a-2*r)*rand(n,1),r + (b-2*r)*rand(n,1)];
Every row should be seen as one vector. Now I want to check the Euclidean norm/distance of each row with all other rows.
So I want to check norm ( row1 -row2), (row1-row3) etc. but also (row 4 - rown).
Thanks for your help!
With this for loop I can check the Euclidean norm/distance with row1 to all others. But I dont know how to check now row 3 and 4 etc.
for i = 1:n
norm(p(i,:)-p(1,:))
end

Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Jun. de 2021
dists = pdist(p);
The default is euclidean norm.
The result would be n x n

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by