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
Image Analyst 2022 年 7 月 27 日

0 投票

% 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 ExchangeShifting and Sorting Matrices についてさらに検索

製品

リリース

R2022a

質問済み:

2022 年 7 月 27 日

回答済み:

2022 年 7 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by