Laying Out a GUI (Using GUIDE)


GUIDE, the MATLAB Graphical User Interface development environment, provides a set of tools for creating graphical user interfaces (GUIs). These tools simplify the process of laying out and programming GUIs.


Laying Out a GUI

The GUIDE Layout Editor enables you to populate a GUI by clicking and dragging GUI components -- such as buttons, text fields, sliders, axes, and so on -- into the layout area. It also enables you to create menus and context menus for the GUI. Other tools, which are accessible from the Layout Editor, enable you to size the GUI, modify component look and feel, align components, set tab order, view a hierarchical list of the component objects, and set GUI options.

A graphical user interface (GUI) is a graphical display that contains devices, or components, that enable a user to perform interactive tasks. To perform these tasks, the user of the GUI does not have to create a script or type commands at the command line. Often the user does not have to know the details of the task at hand.


Opening a New GUI using GUIDE

  1. Start GUIDE by typing guide at the MATLAB prompt. This displays the GUIDE Quick Start dialog.
  2. In the Quick Start dialog, select the Blank GUI (default) template. Click OK to display the blank GUI in the Layout Editor.
  3. Display the names of the GUI components in the component palette. Select Preferences from the MATLAB File menu. Then select GUIDE -> Show names in component palette, and click OK.

The Layout Editor then appears as shown in the following figure. All the tools on the layout editor have also been explained (click picture for enlarged version).

Adding Components

  1. You can add any component from the component palette at the left of the Layout Editor. Simply select any of the components that you want to add and drag it into the layout area.

Editing Text

  1. To edit any title name or any form of text, double click on the component in the layout area and the Property Inspector box will open up (Alternately, select the component and select Property Inspector from the View menu).
  2. In the Property Inspector, select the String property and then replace the existing value with the text that you want to be displayed.

Saving and Running the GUI layout

  1. When you save a GUI, GUIDE creates two files, a FIG-file and an M-file. The FIG-file, with extension .fig, is a binary file that contains a description of the layout. The M-file, with extension .m, contains the code that controls the GUI.
  2. Run your GUI by selecting Run from the Layout Editor Tools menu. If the GUI is on your MATLAB path or in your current directory, you can also run it by typing its name at the command prompt.
  3. Note that once you run the GUI, it turns active. The difference being that nothing will happen even if you play around with components in the layout area because there is no code in the M-file to service the components. The next step is to program the GUI. The next topic, Programming the GUI, shows you how to do this.

More Help?

  1. For more help and instructions on laying out a GUI, refer to the Matlab Documentation, or if needed, refer to the video on this link for more information.