calculate the distance between 2 points

68 visualizaciones (últimos 30 días)
Majid Al-Sirafi
Majid Al-Sirafi el 22 de Mzo. de 2012
Comentada: jaafar rashid el 11 de Nov. de 2023
hi every one i want to calculate the distance between 2 points(p1 & p2), so which of the following equation choose to do that:-
d = (x(p1)-x(p2))^2+(y(p1)-y(p2))^2;
or
d = sqrt((x(p1)-x(p2))^2+(y(p1)-y(p2))^2);
or any one from the above equations
thanks

Respuesta aceptada

Grzegorz Knor
Grzegorz Knor el 22 de Mzo. de 2012
The common use distance formula is the second one:
d = sqrt((x(p1)-x(p2))^2+(y(p1)-y(p2))^2);
  11 comentarios
Daniel Shub
Daniel Shub el 25 de Mzo. de 2012
@majid, but in what direction?
Majid Al-Sirafi
Majid Al-Sirafi el 25 de Mzo. de 2012
one point to the left and another to the right

Iniciar sesión para comentar.

Más respuestas (1)

Jan
Jan el 22 de Mzo. de 2012
You can simply try it, if you are not familiar with the Euclidean Norm (hint: use this term to ask Google or WikiPedia):
Set the variables to coordinates, whichj have a known distance, e.g. [0,0] and [2,0].

Categorías

Más información sobre Particle & Nuclear Physics en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by