code_junkie

How to check if a figure is opened and how to close it

Nov 13th, 2011
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. hFig = figure(...your arguments here...);
  2.  
  3. hFig = findobj(...your property/value pairs here...);
  4.  
  5. close(hFig);
  6. delete(hFig);
  7.  
  8. ishandle(hFig) % Returns 'true' if the figure exists, 'false' if it doesn't
  9.  
  10. get(hFig,'Visible') % Returns 'on' or 'off'
  11. set(hFig,'Visible','off') % Makes a figure invisible,
  12. % but it still exists (i.e. it's not closed)
  13.  
  14. >> close all
  15. >> get(0,'children')
  16. ans =
  17. Empty matrix: 0-by-1
  18. >> figure(1)
  19. >> get(0,'children')
  20. ans =
  21. 1
  22. >> figure(3)
  23. >> get(0,'children')
  24. ans =
  25. 3
  26. 1
  27.  
  28. isempty(findobj('name','Your_Figure_Name'))
Add Comment
Please, Sign In to add comment