MATLAB Answers

0

distance between two points

Asked by Guido Pastore on 15 Mar 2019
Latest activity Commented on by Stephan
on 15 Mar 2019
Hello,
given two double matrices of size (606x3), where each column indicates the XYZ coordinates of a point.
How can I calculate the distance between the two points ??

  0 Comments

Sign in to comment.

Tags

2 Answers

Answer by Stephan
on 15 Mar 2019
 Accepted Answer

dist = sqrt((A(:,1)-B(:,1)).^2 + (A(:,2)-B(:,2)).^2 + (A(:,3)-B(:,3)).^2);

  1 Comment

Thank You so much

Sign in to comment.


Answer by Torsten
on 15 Mar 2019
Edited by Torsten
on 15 Mar 2019

You mean "where each row indicates the XYZ coordinates of a point" ? And you want to calculate the distance between the corresponding points of the two matrices ?
dist = vecnorm(A-B,2,2)

  2 Comments

Thank you so much
more smart solution

Sign in to comment.