MATLAB: Pausing the program for GUI

guiguidematlab functionmatlab guioop

i have a code which does some calculation, then calls the GUI. In the GUI i have some options for user to select from. based on that answer, further calculation is done.
Function this = random(this)
...some calc
...some calc
...some calc
...some calc
GUI % calls the GUI
value = getappdata(0,'value') %gets the value from the GUI
...some calc
...some calc
end
the problem is when I compile, it calls the GUI and continues with the program. how do i make the program wait until a button is pressed in the GUI?

Best Answer

Use waitfor function