Plot a polygon without intersection

Hi everyone I have the matrix below and 1st row refers x-coordinates and 2nd row refers y-coordinates. When I plot it, I get the polygon that I do not want with several intersections due to array of the elements in the out matrix. You can see in the figure below. So, How can I arrange of the elements' array of this matrix to get smooth polygon. For example, the points should be in this aray (1,4) , (2,4) , (3,4) , (3,5) , (2,5) , (1,5). of course, the first point can be changed.
out = [ 1 1 2 2 3 3;
4 5 4 5 4 5]
pgon = polyshape([out(1,:)], [out(2,:)]);
plot(pgon)
grid on
Screen Shot 2019-05-18 at 1.24.05 AM.png

 採用された回答

Walter Roberson
Walter Roberson 2019 年 5 月 18 日

0 投票

k = boundary(out.');
plot(out(1,k), out(2,k))
... but it will just look like a square.

1 件のコメント

skinny pete
skinny pete 2019 年 5 月 18 日
編集済み: skinny pete 2019 年 5 月 18 日
Thank you for your interest. Your answer inspired me to use boundary elements of the matrix. So I changed my code like below.
pgon = polyshape([max(out(1,:)),max(out(1,:)),min(out(1,:)),min(out(1,:))], [min(out(2,:)),max(out(2,:)),max(out(2,:)),min(out(2,:))]);
plot(pgon)
grid on

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeComputational Geometry についてさらに検索

タグ

質問済み:

2019 年 5 月 18 日

編集済み:

2019 年 5 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by