Main Content

regions

访问 polyshape 区域

说明

示例

polyout = regions(polyin) 返回由 polyshape 对象组成的向量,其元素是输入 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])

polyout = regions(polyin)
polyout = 
  2x1 polyshape array with properties:

    Vertices
    NumRegions
    NumHoles

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

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

输入参数

全部折叠

输入 polyshape,指定为标量。

数据类型: polyshape

版本历史记录

在 R2017b 中推出