I have a GUI that sometime at the end displays a new figure (handles.hf5). I create the new figure using:
handles.hf5=figure('position',[xpos, ypos, sz(2), sz(1)]);
When I run my GUI again, if this figure exists, I want to be able to close it. (sometimes I run the GUI with other options and no additional figure is required and so handles.hf5 does not exist.
I have tried the following but none work:
close all allPlots = findall(0, 'Type', 'figure', 'FileName', [])delete(allPlots);
and
if ishandle(handles.hf5) close(handles.hf5) end
Best Answer