Creating Graphical User Interfaces |
Output Function
The output function returns, to the command line, outputs that were generated during execution. It is executed when the opening function returns control and before control returns to the command line. This means that you must generate the outputs in the opening function, or call uiwait
in the opening function to pause its execution while other callbacks generate outputs. See Example: Using the Modal Dialog to Confirm an Operation for an example that uses uiwait
.
Naming and Template
GUIDE names the output function by appending _OutputFcn
to the name of the M-file. This is an example of an output function template as it might appear in the mygui
M-file.
% --- Outputs from this function are returned to the command line. function varargout = mygui_OutputFcn(hObject, eventdata,... handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output;
Input Arguments
The output function has three input arguments: hObject
, eventdata
, and handles
. They are the same as described in Component and Figure Callbacks.
Output Arguments
The output function has one output argument, varargout
, which it returns to the command line. By default, the output function assigns handles.output
to varargout
. So the default output is the handle to the GUI, which was assigned to handles.output
in the opening function.
handles.output
. It can be any valid MATLAB value including a structure or cell array.
varargout
.
varargout
is a cell array. It can contain any number of output arguments. By default, GUIDE creates just one output argument, handles.output
. To create an additional output argument, create a new field in the handles
structure and add it to varargout
using a command similar to
Initialization Callbacks in GUIDE | Managing Application-Defined Data |
© 1994-2005 The MathWorks, Inc.