How do I trace the points with a "snake" pattern?
Show older comments
I want to start at the top left yellow point, trace up with a curve to the corresponding left orange point. Shift to the right and follow the same pattern back down to the second corresponding yellow point. Shift right go up and repeat until all points are used.
(the black circle is to show the start of the triangular figure, I do not need it in my tracing.)

Answers (1)
Image Analyst
on 27 Jul 2022
% Sort the yellow data from right to left.
[yellowx, sortOrder] = sort(yellowx(:), 'descend');
% sort y the same way.
yellowy = yellowy(sortOrder)'; % Column vector.
% Sort the orange data from left to right.
[orangex, sortOrder] = sort(orangex(:), 'ascend');
% sort y the same way.
orangey = orangey(sortOrder)'; % Column vector.
xBoth = [yellowx; orangex];
yBoth = [yellowy; orangey];
plot(xBoth, yBoth, 'k-', 'LineWidth', 2);
grid on;
Categories
Find more on Shifting and Sorting Matrices 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!