Borrar filtros
Borrar filtros

How to obtain Euclidean Distance for multiple points?

7 visualizaciones (últimos 30 días)
Selina Loh
Selina Loh el 20 de Oct. de 2017
Respondida: KSSV el 20 de Oct. de 2017
How to obtain Euclidean Distance for multiple points?
After using the plotmatrix function to plot the graph. Is it possible to calculate the Euclidean Distance for the points ploted?

Respuestas (2)

Walter Roberson
Walter Roberson el 20 de Oct. de 2017
nx = size(X,2);
ny = size(Y,2);
dists = cell(nx, ny);
for yidx = 1 : ny
for xidx = 1 : nx
dists{xidx, yidx} = squareform( pdist( [X(:,xidx), Y(:,yidx)] ) );
end
end
dists will now be a cell array of matrices, each of which is a square matrix giving the distance from every point in the column combination to each other point in that combination.
I had to assume here that your X and Y might contain multiple columns, since that is the main reason to use plotmatrix()

KSSV
KSSV el 20 de Oct. de 2017
As you have data in hand you can use the formula of Euclidean distance....if you have multiple points have a look on pdist.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by