メインコンテンツ

holes

R2026b

polyshape の穴の境界を polyshape オブジェクトの配列に変換

説明

polyout = holes(polyin) は、polyshape オブジェクトの穴の境界を polyshape オブジェクトの配列として返します。polyout の要素数は、polyin の穴の境界の数と同じです。

例

例

すべて折りたたむ

2 つの固体領域と 2 つの穴をもつ多角形を作成します。穴の境界を polyshape オブジェクトの配列に変換します。

P = [0 0; 0 2; 2 2; 2 0; NaN NaN; 0.5 0.5; 0.5 1.5; 1.5 1.5; 1.5 0.5; ...
    NaN NaN; 3 0.5; 3.5 1.5; 4 0.5; NaN NaN; 3.25 0.6; 3.75 0.6; 3.5 1];
polyin = polyshape(P);
plot(polyin)
xlim([-0.5 4.5])
ylim([-0.5 2.5])

Polygon with two solid regions, a square with a square hole and a triangle with a triangular hole

polyout = holes(polyin)
polyout = 
  2×1 polyshape array with properties:

    Vertices
    NumRegions
    NumHoles

plot(polyout)
xlim([-0.5 4.5])
ylim([-0.5 2.5])

Two polyshape objects representing the extracted hole boundaries, a square and a small triangle

入力引数

すべて折りたたむ

入力 polyshape。スカラーとして指定します。

データ型: polyshape

バージョン履歴

R2017b で導入