Reorder Sets of Coordinates into Continuous Path

1 次查看(过去 30 天)
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 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by