To summarize my and OCDER's suggestions:
Toggle the visibility of the GUI with
handles.GUI.Visible = 'off';
In the case of a malfunction when the GUI is inivisible one option is to set a try/catch as OCDER suggested in the comments above. handles.GUI.Visible = 'off';
try
Out = NewGUI(handles.GUI.Position, ...
catch E
disp(E);
handles.GUI.Visible = 'on';
end
handles.GUI.Visible = 'on';
The second option is more reactionary and not automatic. You could write a simple function that searches for your invisible GUI and turns it back on. You could call this function from the command window or from a button in the visible GUIs whenever an error occurs. Of course you won't have the GUI handle any more so you have to search for it.
This function finds all figures, determines which ones are invisible, and turns those ones on.
function h = findMyInvisibleGUI()
allFigHandles = findall(0, 'Type', 'figure');
visibleStatus = get(allFigHandles, 'Visible');
isOff = strcmpi(visibleStatus, 'off');
h = allFigHandles(isOff);
set(h, 'Visible', 'on')
Best Answer