MATLAB: Restart GUI with code

restart gui

Hello!
I am writing a GUI programmatically (not with GUIDE). Is it possible to close and re-open the GUI with a pushbutton callback within that very GUI? If so, how do I code it? I have been looking everywhere, I cannot find anything.
Thanks so much for any help!

Best Answer

If the GUI creator function is called OpenGUI:
function PushButtonCallback(ObjH, EventData)
OrigDlgH = ancestor(ObjH, 'figure');
delete(OrigDlgH);
OpenGUI;
end
So simply close the existing dialog and create a new one. Or do it the other way around.