How to find the distances between two points in X-Y plane?

6 visualizaciones (últimos 30 días)
Anna
Anna el 20 de Sept. de 2019
Respondida: Bhaskar R el 20 de Sept. de 2019
I have two matrices with x values in column 1 and y values in column 2.
I have to find the distances between the values in matrix 1 and matrix 2.
Is there a function to directly find the euclidean distance between the points in both the matrices?

Respuesta aceptada

darova
darova el 20 de Sept. de 2019
Use euclidean distance
1111Untitled.png
d = sqrt( (x2-x1).^2 + (y2-y1).^2 );

Más respuestas (1)

Bhaskar R
Bhaskar R el 20 de Sept. de 2019
You can use
pdist
command if you have Statistics and Machine Learning Toolbox with different variations of distance metrics like euclidean, cosine, hamming, etc

Categorías

Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by