User`s guide
Initialize a GUIDE GUI
Initialize a GUIDE GUI
In this section...
“Opening Function” on page 8-25
“Output F unction” on page 8-28
Opening Function
The opening function is the first callback in every GUI code file. It is executed
justbeforetheGUIismadevisibletotheuser,butafterallthecomponents
have been created, i.e., after the components’
CreateFcn callbacks, if any,
have been run.
You can use the opening function to perform your initialization tasks before
the user has access to the G UI. For example, you can use it to create data or
to read data from an external source. GUI command-line arguments are
passed to the opening function.
• “Function Naming and Template” on page 8-25
• “Input Arguments” on pag e 8-26
• “Initial Template Code” on page 8-28
Function Naming and Template
GUIDE names the opening function by appending _OpeningFcn to the name
of the GUI. This is an exam ple of an opening function template as it might
appear in the
mygui code file.
% --- Executes just before mygui is made visible.
function mygui_Ope ningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future v ersion of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to mygui (see VARARGIN)
% Choose default command line output for mygui
handles.output = hObject;
8-25