How do I trace the points with a "snake" pattern?

조회 수: 4 (최근 30일)
Avril Cruz
Avril Cruz 2022년 7월 27일
답변: Image Analyst 2022년 7월 27일
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일
% 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;

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by