Hai,
I need to find the distance between two points in the figure, which I have plotted. Is there any function in matlab that could find the distance between two points. Looking for your reply.
BSD
No products are associated with this question.
You can use the pdist function in the Statistics Toolbox:
e.g: distance between points (0,0) and (2,1)
>> X = [0,0;2,1]; >> d = pdist(X,'euclidean') d =
2.2361
No. You will have to code it yourself.
There are many different possible meanings for "distance". See http://en.wikipedia.org/wiki/Metric_%28mathematics%29#Examples
Pos=[x1 x2;y1 y2] D=dist(Pos);
@Walter, just the dist() function in MATLAB, not associated to any particular Toolbox. help dist or doc dist will brings it up.
There are many call syntax of dist(). I though the OP wants the Euclidean distance between two points (x1,y1), (x2,y2), which should be sqrt((x1-x2)^2+(y1-y2)^2).
dist() can calculate the Euclidean distance of multiple points at once, it can certainly be used to calculate the distance for two points, although it seems to be an over-kill because the equation sqrt((x1-x2)^2+(y1-y2)^2) can do that too.
Since the OP asked for a MATLAB function, I thought this is the one.
pos=rand(2,5)
D=dist(pos)
Sorry, Walter. You are right, the dist() function is from the Neural Network Toolbox.
I am using my new MATLAB version today. It has a bunch of toolbox. Nice!
0 Comments