Distance Matrix to coordinates in Matlab?
6 views (last 30 days)
Show older comments
Hi I have a 6x6 distance matrix for which i have to find the coordinates. I have no clue of how to do it. Friends pls help me.. The distance matrix is [0 8 8 5 2 8; 8 0 6 3 9 3; 8 6 0 6 8 3; 5 3 6 0 6 4; 2 9 8 6 0 8; 8 3 3 4 8 0] This is going to be the input the traveling salesman code which i have to create. I find a lot of suggestions for converting coordinates to distance matrix but my case is the opposite, and I find it very difficult to crack this one.
2 Comments
Roger Stafford
on 17 May 2013
Perhaps I have misunderstood your question, but are you trying to do something like the inverse of the 'pdist' function - you want to find the coordinates of six points (observations) for which your six-by-six matrix is the corresponding distance matrix (after conversion to vector form)?
In general, I judge that would require at least five dimensions (variables), but in any event a solution would certainly not be unique. There would exist an infinite continuum of them.
Please explain your question in far, far greater detail than you have.
Answers (3)
Victor Prohorov
on 18 Dec 2020
cmdscale
You are all stupid, and I am clever because I am russian
0 Comments
Jan
on 17 May 2013
There is no unique solution, because the final pattern can be rotated, translated and mirrored. So you can choose one solution by setting the first point to the origin and the 2nd point on the X-axis with the distance 8. Now there are two possible locations for the third point with the distances 8 from the 1st point and 6 from the 2nd point: One above and one below the X-axis. Choosing the positive Y-position is fair. Now you can construct the other points easily by further triangulations.
0 Comments
Roger Stafford
on 17 May 2013
This looks to be an impossible problem. Number the points according to the distance matrix rows or columns they correspond to. Points 2, 4, and 1 form a 3-5-8 triangle which must therefore be a straight line segment no matter how it is oriented or how many dimensions are used. Similarly points 2, 4, 5 make a 3-6-9 triangle which must therefore be a line colinear with the first line segment. That would force a distance of 1 between points 1 and 5 on the common line. Unfortunately the matrix says 2 for that distance!
The fact that points 2, 3, and 6 must also be in a straight line introduces even further difficulties.
Someone was playing games when they made up this distance matrix.
0 Comments
See Also
Categories
Find more on Traveling Salesman (TSP) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!