I'm trying to use a GUI inside a M-file function.
I want the function to wait until an exit button is used on the GUI. Once the exit button is pushed I want to save the information from the GUI handle and than close the GUI.
Try defining the figure's CloseRequestFcn as 'myCloseRequestFcn' (arbitrary name) in the property window, then set up that function to do whatever you need to do in the code.