Creating Graphical User Interfaces | ![]() ![]() |
MATLAB implements GUIs as figure windows containing various styles of uicontrol objects. You must program each object to perform the intended action when activated by the user of the GUI. In addition, you must be able to save and launch your GUI. All of these tasks are simplified by GUIDE, MATLAB's Graphical User Interface Development Environment.
GUI Development Environment
The process of implementing a GUI involves two basic tasks:
GUIDE is primarily a set of layout tools. However, GUIDE also generates an M-file that contains code to handle the initialization and launching of the GUI. This M-file also provides a framework for the implementation of the callbacks - the functions that execute when users activate a component in the GUI.
The Implementation of a GUI
While it is possible to write an M-file that contains all the commands to lay out a GUI, it is easier to use GUIDE to lay out the components interactively and to generate two files that save and launch the GUI:
Note that the application M-file does not contain the code that lays out the uicontrols; this information is saved in the FIG-file.
The following diagram illustrates the parts of a GUI implementation.
Features of the GUIDE-Generated Application M-File
GUIDE simplifies the creation of GUI applications by automatically generating an M-file framework directly from your layout. You can then use this framework to code your application M-file. This approach provides a number of advantages:
You can elect to have GUIDE generate only the FIG-file and write the application M-file yourself. There are no uicontrol creation commands in the application M-file; the layout information is contained in the FIG-file generated by the Layout Editor.
Beginning the Implementation Process
To begin implementing your GUI, proceed to the following sections:
![]() | Creating GUIs with MATLAB | Editing Version 5 GUIs with Version 6 GUIDE | ![]() |