ヘルプ センターヘルプ センター
polyshape の領域の並べ替え
polyshape
polyout = sortregions(polyin,criterion,direction)
polyout = sortregions(polyin,'centroid',direction,'ReferencePoint',point)
例
polyout = sortregions(polyin,criterion,direction) は、指定した criterion と direction に従って領域が並べ替えられた polyshape オブジェクトを返します。たとえば、polyout = sortregions(polyin,'area','ascend') は、固体領域が polyin と同じであり、面積の昇順でリストされている polyshape を返します。
polyin
criterion
direction
polyout = sortregions(polyin,'area','ascend')
polyout = sortregions(polyin,'centroid',direction,'ReferencePoint',point) は、各領域の重心と基準点との距離に基づいて領域が並べ替えられた polyshape を返します。
'centroid'
point
すべて折りたたむ
多角形の各領域をまず並べ替えて、それらを識別およびアクセスできるようにします。
2 つの固体領域と 1 つの穴がある多角形を作成します。
t = 0.05:0.5:2*pi; x1 = cos(t); y1 = sin(t); x2 = 0.5*cos(t); y2 = 0.5*sin(t); x3 = 2*cos(t); y3 = 2*sin(t); polyin = polyshape({x1,x2,x3},{y1,y2,y3})
polyin = polyshape with properties: Vertices: [41x2 double] NumRegions: 2 NumHoles: 1
plot(polyin)
この多角形の領域を周囲長に基づいて昇順に並べ替えます。次に、関数 regions を使用して、polyshape オブジェクトの配列 R を作成することができます。R の各要素は polyout の各領域に対応します。R の要素は polyout の領域と同じ順序でインデックス付けされ、このインデックスに基づいて各領域へのアクセスや計算ができるようになります。
regions
R
polyout
polyout = sortregions(polyin,'perimeter','ascend'); R = regions(polyout); plot(R)
smallregion = area(R(1))
smallregion = 0.7541
bigregion = area(R(2))
bigregion = 9.0488
入力 polyshape。スカラー、ベクトル、行列または多次元配列として指定します。
データ型: polyshape
'area'
'perimeter'
'numsides'
並べ替え基準。次の値のいずれかとして指定します。
'area' — 領域の面積の順に並べ替え。
'perimeter' — 領域の周囲長の順に並べ替え。
'numsides' — 各領域の辺の数の順に並べ替え。
'centroid' — 各領域の重心と基準点 (0,0) との距離の順に並べ替え。
'ascend'
'descend'
並べ替える方向。'ascend' または 'descend' として指定します。
[0 0]
基準点。2 要素の行ベクトルとして指定します。1 番目の要素は基準点の x 座標で、2 番目の要素は y 座標です。
R2017b で導入
sortboundaries | polyshape | regions
sortboundaries
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office