MATLAB Answers

Anna
0

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

Asked by Anna
on 20 Sep 2019 at 11:55
Latest activity Answered by Bhaskar R on 20 Sep 2019 at 12:17
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?

  0 Comments

Sign in to comment.

2 Answers

Answer by darova
on 20 Sep 2019 at 12:11
 Accepted Answer

Use euclidean distance
1111Untitled.png
d = sqrt( (x2-x1).^2 + (y2-y1).^2 );

  0 Comments

Sign in to comment.


Answer by Bhaskar R on 20 Sep 2019 at 12:17

You can use
pdist
command if you have Statistics and Machine Learning Toolbox with different variations of distance metrics like euclidean, cosine, hamming, etc

  0 Comments

Sign in to comment.