Main Content

检验有效句柄

使用 isgraphics 确定变量是否为有效的图形对象句柄。句柄变量(在本例中是 h)仍可存在,但如果其引用的对象已删除,则不是有效句柄。

h = plot(1:10);
...
close % Close the figure containing the plot
whos
Name      Size            Bytes  Class                       Attributes

  h       1x1             104    matlab.graphics.chart.primitive.Line 

检验 h 的有效性:

isgraphics(h)
ans =

     0

有关被删除句柄的详细信息,请参阅删除的句柄对象