Files Generated by GUIDE
mygui.m, then the name of the main function is mygui. Each callback in the file is a local
function of that main function.
When GUIDE generates a code file, it automatically includes templates for the most
commonly used callbacks for each component. The code file also contains initialization
code, as well as an opening function callback and an output function callback. It is your
job to add code to the component callbacks for your program to work as you want. You
can also add code to the opening function callback and the output function callback. The
UI code file orders functions as shown in the following table.
Section Description
Comments Displayed at the command line in response to the help
command.
Initialization GUIDE initialization tasks. Do not edit this code.
Opening function Performs your initialization tasks before the user has access to
the UI.
Output function Returns outputs to the MATLAB command line after the
opening function returns control and before control returns to
the command line.
Component and figure
callbacks
Control the behavior of the UI window and of individual
components. MATLAB software calls a callback in response to a
particular event for a component or for the figure itself.
Utility/helper
functions
Perform miscellaneous functions not directly associated with an
event for the figure or a component.
Adding Callback Templates to an Existing UI Code File
When you save the UI, GUIDE automatically adds templates for some callbacks to the
code file. If you want to add other callbacks to the file, you can easily do so.
Within GUIDE, you can add a local callback function template to the code in any of the
following ways. Select the component for which you want to add the callback, and then:
- Right-click the mouse button, and from the View callbacks submenu, select the
desired callback. - From View > View Callbacks, select the desired callback.