8 Programming a GUIDE UI
Function Naming and Template
GUIDE names the output function by appending _OutputFcn to the name of the UI.
This is an example of an output function template as it might appear in the myui code
file.
% --- Outputs from this function are returned to the command line.
function varargout = myui_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 “GUIDE Callback Syntax” on page 8-5.
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.
You can change the output by taking one of these actions:
- Change the value of handles.output. It can be any valid MATLAB value including
a structure or cell array. - Add output arguments to varargout. The varargout argument 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
varargout{2} = handles.second_output;