To delay a GUIDE-GUI output until the GUI is closed, follow these steps. A functional demo is attached that produces an empty GUI and returns a hard-coded output when the GUI is closed. See comments in the m-file for help.
1) If your GUI does not already have a close request function, add one from within GUIDE by opening your GUI in GUIDE, right click the figure background, select View Callbacks, and the select CloseRequestFcn.
2) In the ..._OpeningFcn
function demoGui_OpeningFcn(hObject, eventdata, handles, varargin)
. . .
uiwait();
3) In the ..._outputFcn
function varargout = demoGui_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
delete(hObject);
4) In the ..._CloseRequestFcn you created from GUIDE,
function figure1_CloseRequestFcn(hObject, eventdata, handles)
handles.output = 3.1415926;
guidata(hObject, handles);
uiresume()
[Original answer has been edited]
Best Answer