Reorder Sets of Coordinates into Continuous Path
1 view (last 30 days)
Show older comments
Say I have a series of coordinates represented by matrices:
%[x1 y1; x2 y2;...]
a = [0 0; 2 3; 4 5; 5 4];
b = [0 0; 4 2; 5 5; 1 1];
c = [2 2; 6 7; 3 3; 1 1];
I would like to reorder them to form a continous path in the correct order without repeats, i.e.
aNew = [5 4; 4 5; 2 3; 0 0];
bNew = b; %remains the same since the end of "aNew" is the start of "b"
cNew = [1 1; 3 3; 6 7; 2 2];
compiled = [5 4; 4 5; 2 3; 0 0; 4 2; 5 5; 1 1; 3 3; 6 7; 2 2];
The "start" and "end" coordinates aren't a concern; "a" and "c" in the example above could stay the same while only "b" is rearranged. Is there an efficient MATLAB indexing method to reorder and compile the coordinates?
0 Comments
Answers (0)
See Also
Categories
Find more on Matrix Indexing 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!