How does the code that is automatically generated by GUIDE work?

2 views (last 30 days)
The format of the function that is automatically generated by GUIDE has changed from MATLAB 6.1 (R12.1) to MATLAB 6.5 (R13). There now appear to be additional functions that allow more control over the GUI.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 21 Jan 2010
An additional function used for GUI programming called GUI_MAINFCN, was introduced in MATLAB 6.5 (R13). This function is used to initialize the GUI and its layout. It is also used to dispatch the GUI's callback functions. The use of GUI_MAINFCN allows the creation of two additional functions, OpeningFcn and OutputFcn, which are not part of a normal figure.
The GUI's OpeningFcn is called just before the GUI is made visible during initialization. The OpeningFcn is used for initialization commands, which would have been issued in the GUI's main function in MATLAB 6.1 and 6.0. Using the OpeningFcn makes it possible to alter a GUI before it is rendered on the screen.
The GUI's OutputFcn is used to specify the output from the GUI:
h = mygui
The default output is the handle of the GUI figure. The OutputFcn runs after the OpeningFcn has completed execution and the figure is made visible. If the WAITFOR or UIWAIT functions are used to block execution of the OpeningFcn, then the OutputFcn will be run after the call to WAITFOR has returned. For information on WAITFOR or UIWAIT refer to the documentation by typing:
doc waitfor
or
doc uiwait
at the MATLAB command prompt.

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!