How do I trace the points with a "snake" pattern?
显示 更早的评论
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.)

回答(1 个)
Image Analyst
2022-7-27
% 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;
类别
在 帮助中心 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!