A MATLAB® GUI is a figure window to which you add user-operated controls. You can select, size, and position these components as you like. Using callbacks you can make the components do what you want when the user clicks or manipulates them with keystrokes.
You can build MATLAB GUIs in two ways:
Use GUIDE (GUI Development Environment), an interactive GUI construction kit.
Create code files that generate GUIs as functions or scripts (programmatic GUI construction).
The first approach starts with a figure that you populate with components from within a graphic layout editor. GUIDE creates an associated code file containing callbacks for the GUI and its components. GUIDE saves both the figure (as a FIG-file) and the code file. Opening either one also opens the other to run the GUI.
In the second, programmatic, GUI-building approach, you create a code file that defines all component properties and behaviors; when a user executes the file, it creates a figure, populates it with components, and handles user interactions. The figure is not normally saved between sessions because the code in the file creates a new one each time it runs.
As a result, the code files of the two approaches look different. Programmatic GUI files are generally longer, because they explicitly define every property of the figure and its controls, as well as the callbacks. GUIDE GUIs define most of the properties within the figure itself. They store the definitions in its FIG-file rather than in its code file. The code file contains callbacks and other functions that initialize the GUI when it opens.
MATLAB software also provides functions that simplify the creation of standard dialog boxes, for example to issue warnings or to open and save files. The GUI-building technique you choose depends on your experience, your preferences, and the kind of application you need the GUI to operate. This table outlines some possibilities.
Type of GUI
MATLAB software provides a selection of standard dialog boxes that you can create with a single function call. For an example, see the documentation for msgbox, which also provides links to functions that create specialized predefined dialog boxes.
GUI containing just a few components
It is often simpler to create GUIs that contain only a few components programmatically. You can fully define each component with a single function call.
Moderately complex GUIs
GUIDE simplifies the creation of moderately complex GUIs.
Complex GUIs with many components, and GUIs that require interaction with other GUIs
Creating complex GUIs programmatically lets you control exact placement of the components and provides reproducibility.
You can combine the two approaches to some degree. You can create a GUI with GUIDE and then modify it programmatically. However, you cannot create a GUI programmatically and later modify it with GUIDE.