closing a specified figure (if exist)

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

Accepted Answer

Grzegorz Knor
Grzegorz Knor on 6 Sep 2011
h = figure;
if ishandle(h)
close(h)
end
  4 Comments
Grzegorz Knor
Grzegorz Knor on 6 Sep 2011
close(findobj('type','figure','name','flashing'))

Sign in to comment.

More Answers (2)

Paulo Silva
Paulo Silva on 6 Sep 2011
close(findall(0,'type','figure','name','flashing'))

Zoltan Gal
Zoltan Gal on 13 Apr 2019
If the index of figure is 5, then
close(findobj('type','figure','number',5))

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!