closing a specified figure (if exist)

does anyone know how to close a specified figure if it exists currently? for example: h=figure
if h exists close(h) end

 採用された回答

Grzegorz Knor
Grzegorz Knor 2011 年 9 月 6 日

3 投票

h = figure;
if ishandle(h)
close(h)
end

4 件のコメント

Grzegorz Knor
Grzegorz Knor 2011 年 9 月 6 日
ishandle(h) returns 1 if figure exists and 0 if figure is close.
mohammad
mohammad 2011 年 9 月 6 日
thanks a lot
how can do when i know name of the figure
for example:
h=figure(.........
'Name','flashing', ...)
figure name is:flashing
if 'flashing' exist
close flashing
end
Grzegorz Knor
Grzegorz Knor 2011 年 9 月 6 日
close(findobj('type','figure','name','flashing'))
mohammad
mohammad 2011 年 9 月 6 日
thanks a lot

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

その他の回答 (2 件)

Paulo Silva
Paulo Silva 2011 年 9 月 6 日

3 投票

close(findall(0,'type','figure','name','flashing'))
Zoltan Gal
Zoltan Gal 2019 年 4 月 13 日

0 投票

If the index of figure is 5, then
close(findobj('type','figure','number',5))

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

質問済み:

2011 年 9 月 6 日

回答済み:

2019 年 4 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by