I have a GUI. This GUI runs a simulation the at the end of it I open a figure to display results.
When I re-run the simulation - the old figure is kept open.
How do I close the old figure without closing the GUI?
('close all' close all the windows including the GUI).
In the section of simulation use these line:
handles.H = figure(2)
when you press any button ploter figure automatically will be closed
hFig = figure; surf(peaks);
To close that figure:
I passing here to let my contribution as I had exactly the same problem. If you know the name or tag of the GUI, it is easy:
% Close all figures still openned except the GUI which property 'name' is equal 'nameOfQUI' figHandles = findobj('type', 'figure', '-not', 'name', 'nameOfGUI'); close(figHandles);
% Close all figures still openned except the GUI which property 'tag' is equal 'tagOfQUI' figHandles = findobj('type', 'figure', '-not', 'tag', 'tagOfGUI'); close(figHandles);