68 719
Assignments Done
Successfully Done
In January 2019

Answer to Question #62024 in MatLAB | Mathematica | MathCAD | Maple for Linda

Question #62024
Distance between two points (x1, y1) and (x2, y2) is defined by:
distance = sqrt((x1-x2)^2+(y1-y2)^2)
Write a matlab function computeDistance that computes the distance between two points, with the
following signature.
function d = computeDistance(p1, p2)
p1 - coordinates of the first point as a vector with coordinates [x1 y1]
p2 - coordinates of the second point as a vector with coordinates [x2 y2]
d - the distance between the two points
Expert's answer
function d = computeDistance(p1, p2)
d = sqrt((p1(1)-p2(1))^2+(p1(2)-p2(2))^2);

Apply function:
computeDistance([1 1],[0 0])

ans =

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions