1 Getting Started with GUIDE ."Laying Out GUIs-The Layout Editor"on page 4-2-add and arrange objects in the figure window. Aligning Components in the layout Editor"on page 4-9- align objects with respect to each ·“ Setting Component Properties- The Property Inspector” on page4-14 inspect and set property values. "Viewing the Object hierarchy- The Object Browser"on page 4-16 observe a hierarchical list of the Handle graphies objects in the current MATLAB Session ."Creating Menus- The Menu Editor"on page 4-17-create a menu bar or a context menu for any component in your layou "Setting the Tab Order- The Tab Order Editor"on page 4-27-chang order in which components are selected by tabbing 1-4
1 Getting Started with GUIDE 1-4 • “Laying Out GUIs — The Layout Editor” on page 4-2 — add and arrange objects in the figure window. • “Aligning Components in the Layout Editor” on page 4-9 — align objects with respect to each other. • “Setting Component Properties — The Property Inspector” on page 4-14 — inspect and set property values. • “Viewing the Object Hierarchy — The Object Browser” on page 4-16 — observe a hierarchical list of the Handle Graphics objects in the current MATLAB session. • “Creating Menus — The Menu Editor” on page 4-17 — create a menu bar or a context menu for any component in your layout. • “Setting the Tab Order — The Tab Order Editor” on page 4-27 — change the order in which components are selected by tabbing
GUI FIG-Files and M-files GUI FIG-Files and M-Files GUidE stores GUIs in two files, which are generated the first time you save or run the gui FIG-file-a file with extension. fig that contains a complete description of the GUi figure layout and the components of the GUI: push buttons, menus axes, and so on. When you make changes to the GuI layout in the layout Editor, your changes are saved in the FIg-file M-file- a file with extension m that contains the code that controls the GUl, including the callbacks for its components. This file is referred to as the GUI M-file. When you first run or save a gUI from the Layout Editor GUidE generates the GuI M-file with blank stubs for each of the callbacks You can than program the callbacks using the M-file editor Note In the documentation for releases prior to Release 13, the GUI M-file was referred to as the“ application M-file
GUI FIG-Files and M-Files 1-5 GUI FIG-Files and M-Files GUIDE stores GUIs in two files, which are generated the first time you save or run the GUI: • FIG-file — a file with extension .fig that contains a complete description of the GUI figure layout and the components of the GUI: push buttons, menus, axes, and so on. When you make changes to the GUI layout in the Layout Editor, your changes are saved in the FIG-file. • M-file — a file with extension .m that contains the code that controls the GUI, including the callbacks for its components. This file is referred to as the GUI M-file. When you first run or save a GUI from the Layout Editor, GUIDE generates the GUI M-file with blank stubs for each of the callbacks. You can than program the callbacks using the M-file editor. Note In the documentation for releases prior to Release 13, the GUI M-file was referred to as the “application M-file
1 Getting Started with GUIDE Using GUIDE Templates GUIDE provides templates for several basic types of GUIs. You can modify these templates to make your own GUIs. The advantage of using the templates is that you can create GUIs more quickly and easily To view the templates, enter guide at the matlab prompt. This displays the GUIdE Quick Start dialog, as shown in the following figure Create New GUI Open Existing GUI I GUIDE templates Preview一 volumed)o cu inc s.Unit Sytem r save on startup as: c:workuntited nio When you select a template in the left pane, a preview of it appears in the right pane. Clicking OK opens the template in the layout editor. See "Using GUIDE Templates" on page 3-6 for more information about Guide template detailed example of how to create a GUI using GUID Se 1-1, provides a The next section, "Getting Started with GUiDE on pa 1-6
1 Getting Started with GUIDE 1-6 Using GUIDE Templates GUIDE provides templates for several basic types of GUIs. You can modify these templates to make your own GUIs. The advantage of using the templates is that you can create GUIs more quickly and easily. To view the templates, enter guide at the MATLAB prompt. This displays the GUIDE Quick Start dialog, as shown in the following figure. When you select a template in the left pane, a preview of it appears in the right pane. Clicking OK opens the template in the Layout editor. See “Using GUIDE Templates” on page 3-6 for more information about GUIDE templates. The next section, “Getting Started with GUIDE” on page 1-1, provides a detailed example of how to create a GUI using GUIDE
Example: Creating a gui This section presents an example that shows how to use guide to create graphical user interfaces (GUIs Designing the GUI(p 2-2) Design the gui before actually creating it in gUidE Laying Out the gui(p 2-3) Use the guide Layout Editor to arrange the gui components, such as push buttons, pop-up menus, and Programming the GUI(p 2-9) Use the M-file editor to program the gui Saving and Running the gui(p 2-21) Run the GUI from the layout Editor
2 Example: Creating a GUI This section presents an example that shows how to use GUIDE to create graphical user interfaces (GUIs). Designing the GUI (p. 2-2) Design the GUI before actually creating it in GUIDE. Laying Out the GUI (p. 2-3) Use the GUIDE Layout Editor to arrange the GUI components, such as push buttons, pop-up menus, and axes. Programming the GUI (p. 2-9) Use the M-file editor to program the GUI Saving and Running the GUI (p. 2-21) Run the GUI from the Layout Editor
GUI Designing the GUI The GUI used in this example contains an axes that displays either a surface, mesh, or contour plot of data selected from the pop-up menu. The following picture shows a sketch that you might use as a starting point for the design. Surf Mesh Contour Select dat peaks Menu for selecting data The pop-up menu contains three strings-"peaks, ""membrane, "and"sinc which correspond to MATLAB functions. The user can select the data to plot from this menu 2-2
2 Example: Creating a GUI 2-2 Designing the GUI The GUI used in this example contains an axes that displays either a surface, mesh, or contour plot of data selected from the pop-up menu. The following picture shows a sketch that you might use as a starting point for the design. The pop-up menu contains three strings — “peaks,” “membrane,” and “sinc,” which correspond to MATLAB functions. The user can select the data to plot from this menu. Select Data peaks Contour Mesh Surf Axes Push buttons to select plot type Menu for selecting data