MATLAB: Parent and child gui not working

guidematlab gui

Hello. I bulit a gui using guide which also have a child gui. But when i run the main gui and then open the child, it doesnt execute the code inside the child. How can i resolve this? Thd code that opens the sub_GUI and closes the main windows is written below
open('sub_GUI.fig'); close(gcbf);

Best Answer

Opening the fig file is not sufficient, because it does not start the code to manage the figure, e.g. the OpeningFcn. Open the sub-GUI instead by calling its M-function:
sub_GUI()
To run an app created with GUIDE without opening GUIDE, execute its code
file by typing its name:
simple_gui
*Note:* Do not attempt to run your app by opening its FIG-file outside of
GUIDE. If you do so, the figure opens and appears ready to use, but the UI
does not initialize and the callbacks do not function.
Hint: This link was the 2nd hit, when I ask an internet search engine for "Matlab open GUIDE figure by code". The forum is powerful, but you find many solutions in the net directly also.