distance between two points

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 ??

 Accepted Answer

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

More Answers (1)

Torsten
Torsten on 15 Mar 2019
Edited: 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.

Asked:

on 15 Mar 2019

Commented:

on 15 Mar 2019

Community Treasure Hunt

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

Start Hunting!