Specifications

The Generated M-File
2-17
See Callback Function Syntax for more information on callback function
arguments and Renaming Application Files and Tags for more information on
how to change the names used by GUIDE.
Adding Arguments to the Callback – varargin
Callback subfunctions added by GUIDE require certain arguments, but have a
variable-length argument list. Since the last argument is
varargin, you can
add whatever arguments you want to the subfunction. To pass the additional
arguments, edit the
Callback property’s string to include the arguments. For
example, if the string added automatically to the
Callback property is,
my_gui('pushbutton1_Callback',gcbo,[],guidata(gcbo))
change it using the Property Inspector to include the additional arguments.
For example, changing the
Callback property to,
my_gui('pushbutton1_Callback',gcbo,[],guidata(gcbo),arg1,arg2)
in the Property Inspector:
The subfunction,
pushbutton1_Callback has the syntax
varargout = pushbutton1_Callback(h,eventdata,handles,varargin)
so you can pass the extra input arguments without changing its function
definition line.