Is there a function to turn ?x2 matrix of coordinates of vertices of a polygon into a ?x4 matrix of coordinates of line segments of that polygon?

1 回表示 (過去 30 日間)
Is there a function to turn a matrix of vertices of a polygon like this [2, 4; 5, 6; 6, 6; 8,5] into a matrix of line segments of that polygon like this [2, 4, 5, 6; 5, 6, 6, 6; 6, 6, 8, 5; 8, 5, 2, 4]?

採用された回答

Stephan
Stephan 2019 年 12 月 4 日
Yes,
circshift will do the job:
A = [2, 4; 5, 6; 6, 6; 8,5]
B = [2, 4, 5, 6; 5, 6, 6, 6; 6, 6, 8, 5; 8, 5, 2, 4]
% The solution:
C = [A circshift(A,-1)]
% The test:
A =
2 4
5 6
6 6
8 5
B =
2 4 5 6
5 6 6 6
6 6 8 5
8 5 2 4
C =
2 4 5 6
5 6 6 6
6 6 8 5
8 5 2 4

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeElementary Polygons についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by