MATLAB: Calculate the distance between 2 points

calculate the distanceMapping Toolbox

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

Best Answer

The common use distance formula is the second one:
d = sqrt((x(p1)-x(p2))^2+(y(p1)-y(p2))^2);
Related Question