Creating Graphical User InterfacesVersion 7MATLAB®The Language of Technical Computing
1 Getting Started with GUIDE1-2What Is GUIDE?GUIDE, the MATLAB® Graphical User Interface development environment, provides a set of tools for creating
3 Laying Out GUIs and Setting Properties3-50Set the following panel properties:•BorderType beveledout• BorderWidth 2• HighlightColor (white)-red 1.0-
Setting Component Properties — The Property Inspector3-51Callback PropertiesA callback is a function that executes when a user performs a specific act
3 Laying Out GUIs and Setting Properties3-52The following table lists the various callback properties and briefly describes the purpose of each callba
Setting Component Properties — The Property Inspector3-53• In the View menu, select View Callbacks. Then select the desired callback, e.g., KeyPressFc
3 Laying Out GUIs and Setting Properties3-54Making the Change in the Property Editor. For example, to change the callback name in a push button’s call
Setting Component Properties — The Property Inspector3-55• References in the M-file to the field of the handles structure that contains the component’
3 Laying Out GUIs and Setting Properties3-56Viewing the Object Hierarchy — The Object BrowserThe Object Browser displays a hierarchical list of the ob
Creating Menus — The Menu Editor3-57Creating Menus — The Menu EditorMATLAB enables you to create two kinds of menus:• Menu bar objects — drop-down men
3 Laying Out GUIs and Setting Properties3-58Defining Menus for the Menu BarWhen you create a drop-down menu, MATLAB adds its title to the figure menu
Creating Menus — The Menu Editor3-59Adding Items to a MenuUse the New Menu Item tool to define the menu items that are displayed in the drop-down menu
Starting GUIDE1-3Starting GUIDETo start GUIDE, enter guide at the MATLAB prompt. This displays the GUIDE Quick Start dialog, as shown in the following
3 Laying Out GUIs and Setting Properties3-60For example, to add an Open menu item under File, select File then click the New Menu Item tool. Fill in t
Creating Menus — The Menu Editor3-61To create additional drop-down menus, use the New Menu tool in the same way you did to create the File menu. For e
3 Laying Out GUIs and Setting Properties3-62When you run the GUI, the menu titles appear in the menu bar.
Creating Menus — The Menu Editor3-63Menu CallbacksBy default, the Callback text field in the Menu Editor is set to the string %automatic. This causes
3 Laying Out GUIs and Setting Properties3-64Syntax of the Callback SubfunctionThe GUI M-file contains all callbacks for the GUI, including the menu ca
Creating Menus — The Menu Editor3-65This is the automatically generated callback subfunction that you see if you click the View button after saving th
3 Laying Out GUIs and Setting Properties3-66Note You must select the Menu Editor’s Context Menus tab before you begin to define a context menu.Select
Creating Menus — The Menu Editor3-67You can also • Select the Separator above this item check box to display a separator above the menu item when the
3 Laying Out GUIs and Setting Properties3-68endThis changes the value of the Checked property of the menu item from on to off or vice versa each time
Setting the Tab Order — The Tab Order Editor3-69Setting the Tab Order — The Tab Order EditorA GUI’s tab order is the order in which components of the
1 Getting Started with GUIDE1-4The Layout EditorWhen you open a GUI in GUIDE, it is displayed in the Layout Editor, which is the control panel for all
3 Laying Out GUIs and Setting Properties3-70To examine and change the tab order of the panel components, click the panel background to select it, then
4Programming GUIsUnderstanding the GUI M-File (p. 4-2) The GUI M-file programs the GUI. This section describes the functioning of the GUI M-file, bot
4 Programming GUIs4-2Understanding the GUI M-FileThe GUI M-file generated by GUIDE controls the GUI and determines how it responds to a user’s action,
Understanding the GUI M-File4-3You can retrieve the data in any other callback with the commandX = handles.current_data;For an example of sharing data
4 Programming GUIs4-4• Callbacks — execute each time the user activates the corresponding component of the GUI.Common Input ArgumentsAll functions in
Understanding the GUI M-File4-5my_gui('Position', [71.8 44.9 74.8 19.7]) opens the GUI at the specified position, since Position is a valid
4 Programming GUIs4-6For example, if the GUI contains a push button whose String property is 'Yes', add the following code to its callback t
Understanding the GUI M-File4-7Input and Output ArgumentsThe following examples illustrate various ways to call a GUI named my_gui with different argu
4 Programming GUIs4-8Programming Callbacks for GUI ComponentsThis section explains how to program the callbacks for some specific GUI components. “Cal
Programming Callbacks for GUI Components4-9% toggle button is pressedelseif button_state == get(hObject,'Min')% toggle button is not pressed
The Layout Editor1-5You can also use the Layout Editor to set basic properties of the GUI components. To learn more about the Layout Editor, see “Usin
4 Programming GUIs4-10Note If you have radio buttons that are managed by a button group component, you must include the code to control them in the b
Programming Callbacks for GUI Components4-11You can use the following code in the edit text callback. It gets the value of the String property and con
4 Programming GUIs4-12callback can query the Selection Type property to determine if it was a single- or double-click. List Box ExamplesSee the follow
Programming Callbacks for GUI Components4-13% proceed with callback...PanelsPanels group GUI components and can make a user interface easier to unders
4 Programming GUIs4-14radio button. It then uses the Tag property of the selected object to choose the appropriate code to execute.function uibuttongr
Programming Callbacks for GUI Components4-15Note If your GUI is opened as the result of another GUI’s callback, you might need to explicitly specify
4 Programming GUIs4-16The preceding code performs the following operations:• Reads the image file banner.jpg using the command imread.• Determines the
Programming Callbacks for GUI Components4-17ActiveX ControlsYou can insert an ActiveX control into your GUI if you are running MATLAB on Microsoft Win
4 Programming GUIs4-182 Scroll down the ActiveX Control List and select Mwsamp Control. This displays a preview of the ActiveX control Mwsamp, as show
Programming Callbacks for GUI Components4-194 Click the Run button on the toolbar and save the GUI when prompted. GUIDE displays the GUI shown in the
1 Getting Started with GUIDE1-6GUIDE TemplatesThe GUIDE Quick Start dialog provides templates for several basic types of GUIs. The advantage of using
4 Programming GUIs4-20from the View menu. This displays the Property Inspector, as shown in the following figure.The ActiveX control mwsamp has just t
Programming Callbacks for GUI Components4-21refresh(handles.figure1);4 Add the following command to the opening function:handles.activex1.label = ...[
4 Programming GUIs4-22handles.activex1.radius = ...get(hObject, 'Value')*handles.default_radius;handles.activex1.label = ...['Radius =
Programming Callbacks for GUI Components4-23- Gets the Value of the slider, which in this example is a number between 0 and 1, the default values of t
4 Programming GUIs4-24Alternatively, you can entermethods(hObject)which displays the available methods in the Command Window.For more information abou
Programming Callbacks for GUI Components4-25hidden from plotting commands issued by your GUI. To issue plotting commands from your GUI, • Create a fig
4 Programming GUIs4-26Managing GUI Data with the Handles StructureGUIDE provides a mechanism, called the handles structure, for storing and retrieving
Managing GUI Data with the Handles Structure4-27 Defining the Data Fields in the Opening FunctionThe GUI records the number of times a user enters an
4 Programming GUIs4-28num2str(get(handles.slider1,'Value')));The code combines three commands:• The get command obtains the current value of
Managing GUI Data with the Handles Structure4-29Application DataApplication data provides a way for applications to save and retrieve data stored with
GUIDE Templates1-7To display the names of the GUI components in the component palette, select Preferences from the File menu, check the box next to Sh
4 Programming GUIs4-30Designing for Cross-Platform CompatibilityYou can use specific property settings to create a GUI that behaves more consistently
Designing for Cross-Platform Compatibility4-31Specifying a Fixed-Width FontIf you want to use a fixed-width font for a uicontrol, set its FontName pro
4 Programming GUIs4-32on UNIX). When your GUI is deployed on a different platform, it uses that computer’s standard color. This provides a consistent
Types of Callbacks4-33Types of CallbacksThe primary mechanism for implementing a GUI is programming the callbacks of the GUI components used to build
4 Programming GUIs4-34Callbacks for Specific ComponentsSome components have additional properties that execute callback routines with the appropriate
Interrupting Executing Callbacks4-35Interrupting Executing CallbacksBy default, MATLAB allows an executing callback to be interrupted by subsequently
4 Programming GUIs4-36• drawnow• figure •getframe• pause• waitforWhen MATLAB encounters one of these commands in a callback, it suspends execution and
Interrupting Executing Callbacks4-372 If the event at the top of the queue calls for a figure window redraw, MATLAB performs the redraw and proceeds t
4 Programming GUIs4-38Controlling Figure Window BehaviorWhen designing a GUI you need to consider how you want the figure window to behave. The approp
Controlling Figure Window Behavior4-39the initialization section of the GUI M-file in the opening function with the set command.set(hObject,'Wind
1 Getting Started with GUIDE1-8Running a GUITo run a GUI, select Run from the Tools menu, or click the run button on the toolbar. This displays the
4 Programming GUIs4-40Example: Using the Modal Dialog to Confirm an OperationThis example illustrates how to use the modal dialog GUI together with an
Example: Using the Modal Dialog to Confirm an Operation4-41Note The following links execute MATLAB commands and are designed to work within the MATLA
4 Programming GUIs4-42Setting Up the GUI with the Close ButtonTo set up the second GUI with a Close button, do the following:1 Select New from the Fil
Example: Using the Modal Dialog to Confirm an Operation4-43% eventdata reserved - to be defined in a future version of MATLAB% handles structure w
4 Programming GUIs4-44Clicking the Yes button closes both the close dialog and the GUI that calls it. Clicking the No button closes just the dialog.Ho
Example: Using the Modal Dialog to Confirm an Operation4-454 When a user clicks one of the two push buttons, the callback for the push button- Updates
4 Programming GUIs4-46
5GUI ApplicationsGUI with Multiple Axes (p. 5-2) Analyze data and generate frequency and time domain plots in the GUI figure.List Box Directory Reade
5 GUI Applications5-2GUI with Multiple AxesThis example creates a GUI that contains two axes for plotting data. For simplicity, this example obtains d
GUI with Multiple Axes5-3View Completed Layout and Its GUI M-FileIf you are reading this in the MATLAB Help browser, you can click the following links
GUI FIG-Files and M-Files1-9GUI FIG-Files and M-FilesGUIDE stores a GUI in two files, which are generated the first time you save or run the GUI: • A
5 GUI Applications5-4To create the default values, set the String property of the edit text. The following figure shows the value set for the time vec
GUI with Multiple Axes5-5For example, the Tag of the axes used to display the FFT is set to frequency_axes. Therefore, within a callback, you access i
5 GUI Applications5-6like you would on the command line. Note that Callback is the default setting for command-line accessibility.See “Selecting GUI O
GUI with Multiple Axes5-7• Making the appropriate axes current using the axes command and the handle of the axes. For example,axes(handles.frequency_a
5 GUI Applications5-8plot(t,x)set(handles.time_axes,'XMinorTick','on')grid on
List Box Directory Reader5-9List Box Directory ReaderThis example uses a list box to display the files in a directory. When the user double clicks on
5 GUI Applications5-10Note The following links execute MATLAB commands and are designed to work within the MATLAB Help browser. If you are reading th
List Box Directory Reader5-11• First input argument is not a directory, but is a character string and there is more than one argument — execute the su
5 GUI Applications5-12• Change to the specified directory so the GUI can navigate up and down the tree as required.• Use the dir command to get a list
List Box Directory Reader5-13is a file, it is passed to the open command; if it is a directory, the GUI changes to that directory and lists its conten
1 Getting Started with GUIDE1-10Programming the GUI M-fileAfter laying out your GUI, you can program the GUI M-file using the M-file editor. GUIDE aut
5 GUI Applications5-14index_selected = get(handles.listbox1,'Value');file_list = get(handles.listbox1,'String');filename = file_li
Accessing Workspace Variables from a List Box5-15Accessing Workspace Variables from a List BoxThis GUI uses a list box to display workspace variables,
5 GUI Applications5-16• Delete the string assigned to the list box Callback property.View Completed Layout and Its GUI M-FileIf you are reading this i
Accessing Workspace Variables from a List Box5-17Reading the Selections from the List BoxThis GUI requires the user to select two variables from the w
5 GUI Applications5-18var1 = list_entries{index_selected(1)};var2 = list_entries{index_selected(2)};end Callbacks for the Plotting ButtonsThe callback
A GUI to Set Simulink Model Parameters5-19A GUI to Set Simulink Model Parameters This example illustrates how to create a GUI that sets the parameters
5 GUI Applications5-20all component properties and to understand how the components are assembled to create the GUI. You can also see a complete listi
A GUI to Set Simulink Model Parameters5-21Running the SimulationOnce you have set the gain values, you can run the simulation by clicking the Simulate
5 GUI Applications5-22• Determine if the model is open (find_system).• Open the block diagram for the model and the subsystem where the parameters are
A GUI to Set Simulink Model Parameters5-23• Calls model_open to ensure that the Simulink model is open so that simulation parameters can be set.• Gets
Programming the GUI M-file1-11You can view the callback for any of the GUI components by clicking the function icon on the toolbar. This displays a l
5 GUI Applications5-24• Sets the appropriate block parameter to the new value (set_param).Here is the callback for the Kf Current value text box.funct
A GUI to Set Simulink Model Parameters5-25Here is the Simulate and store results button callback.function SimulateButton_Callback(hObject, eventdata,
5 GUI Applications5-26endset(handles.ResultsList,'String',ResultsStr);% Store the new ResultsDatahandles.ResultsData = ResultsData;guidata(h
A GUI to Set Simulink Model Parameters5-27set(handles.ResultsList,'Value',currentVal,'String',resultsStr)% Store the new ResultsDa
5 GUI Applications5-28currentVal = get(handles.ResultsList,'Value');% Get data to plot and generate command string with color% specifiedlege
A GUI to Set Simulink Model Parameters5-29The GUI Help ButtonThe GUI Help button callback displays an HTML file in the MATLAB Help browser. It uses tw
5 GUI Applications5-30when you add the list box and automatically sets the Callback property to execute this subfunction whenever the callback is trig
An Address Book Reader5-31An Address Book ReaderThis example shows how to implement a GUI that displays names and phone numbers, which it reads from a
5 GUI Applications5-32• The names and phone numbers stored in the MAT-file• An index pointer that indicates the current name and phone number, which m
An Address Book Reader5-33• GUI M-file options selected: Generate callback function prototypesApplication allows only one instance to runCalling the G
How to Contact The MathWorks:www.mathworks.com Webcomp.soft-sys.matlab [email protected] Technical [email protected] Product
1 Getting Started with GUIDE1-12Editing Version 5 GUIs with Version 7 GUIDEIn MATLAB Version 5, GUIDE saved GUI layouts as MAT-file/M-file pairs. Sinc
5 GUI Applications5-34elseif (length(varargin) == 2 & strcmpi(varargin{1},'book') & (2 == exist(varargin{2},'file'))) C
An Address Book Reader5-35Check_And_Load Code ListingThis is the Check_And_Load function.function pass = Check_And_Load(file,handles)% Initialize the
5 GUI Applications5-36elseerrordlg('Not a valid Address Book','Address Book Error')endThe Open Menu CallbackThe address book GUI c
An Address Book Reader5-37• If the name exists in the current address book, the corresponding phone number is displayed.• If the name does not exist,
5 GUI Applications5-38returnendend% If it's a new name, ask to create a new entryAnswer=questdlg('Do you want to create a new entry?',
An Address Book Reader5-39Code Listingfunction Contact_Phone_Callback(hObject, eventdata, handles)Current_Phone = get(handles.Contact_Phone,'stri
5 GUI Applications5-40Determining Which Button Is ClickedThe callback defines an additional argument, str, that indicates which button, Prev or Next,
An Address Book Reader5-41% last element in the Addresses arrayif i < 1i = length(Addresses);endcase 'Next'% Increase the index by onei =
5 GUI Applications5-42Saving the MAT-FileIf the user selects Save, the save command is called to save the current MAT-file with the new names and phon
An Address Book Reader5-43endendThe Create New MenuThe Create New menu simply clears the Contact Name and Contact Phone # text fields to facilitate ad
Editing Version 5 GUIs with Version 7 GUIDE1-13M-file generated by Version 7 GUIDE can provide a model of how to restructure your code.
5 GUI Applications5-44The size of the Contact Name text box changes in proportion to the new figure width. This is accomplished by:• Changing the Unit
An Address Book Reader5-45if Figure_Size(3) < Original_Size(3)% If the width is too small then reset to origianl widthset(hObject, 'Position&a
5 GUI Applications5-46
Index-1IndexAactivate figure 3-19ActiveX controls 4-17aligning GUI components 3-34Alignment Tool, for GUIs 3-34application data 4-29application M-file
IndexIndex-2GUIDE (continued)creating menus 3-57demonstration 2-3editing version 5 GUIs 1-12generated M-file 3-29grids and rulers 3-36GUI background c
IndexIndex-3Ttoggle buttons 4-8toolbar menuscreating with GUIDE 3-58
IndexIndex-4
1 Getting Started with GUIDE1-14
2Creating a GUIDesigning the GUI (p. 2-2) Designing the GUI before actually creating it in GUIDE.Laying Out the GUI (p. 2-3) Using the GUIDE Layout E
2 Creating a GUI2-2Designing the GUIThe GUI used in this example contains an axes that displays either a surface, mesh, or contour plot of data select
Laying Out the GUI2-3Laying Out the GUIThis section illustrates how to lay out GUI components (i.e., a panel, axes, and user interface controls, such
2 Creating a GUI2-4Open a New GUI in the Layout EditorOpen GUIDE by typing guide at the MATLAB prompt. This displays the Guide Quick Start dialog show
Laying Out the GUI2-5To display the names of the GUI components in the component palette, select Preferences from the File menu, check the box next to
2 Creating a GUI2-6Set the GUI Figure SizeSpecify the size of the GUI by resizing the grid area in the Layout Editor. Click on the lower-right corner
Laying Out the GUI2-7Note Setting the Units property to characters gives the GUI a more consistent appearance across platforms.Add the Components1 Ad
iContents1Getting Started with GUIDEWhat Is GUIDE? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2Starting GUIDE
2 Creating a GUI2-8push buttons into the panel. As you move each push button into the panel, GUIDE highlights the panel to indicate that the panel is
Laying Out the GUI2-9Align the ComponentsYou can use the Alignment Tool to align components with respect to one another if they have the same parent.
2 Creating a GUI2-10Now align the tops of the axes and the panel. Note that when the panel moves, its contents move with it.To learn more about the La
Setting Properties for GUI Components2-11Setting Properties for GUI ComponentsTo set the properties of each GUI component, select the Property Inspect
2 Creating a GUI2-12Title PropertyA panel’s Title property controls the title that appears at the top or bottom of the panel. Select the panel in the
Setting Properties for GUI Components2-13When you click on the Layout Editor, the current layout of the GUI appears as in the following figure.
2 Creating a GUI2-14Callback PropertiesComponents use callbacks to do their work. A callback is a function that executes when a user performs a specif
Setting Properties for GUI Components2-15When you first add a component to a layout, GUIDE sets the value of Tag to a default string such as pushbutto
2 Creating a GUI2-16You can redefine the value of Tag to be more descriptive, but the value of each Tag property must be unique for a given GUI. In th
Programming the GUI2-17Programming the GUIAfter laying out the GUI and setting component properties, the next step is to program it. This section expl
ii ContentsSetting Properties for GUI Components . . . . . . . . . . . . . . . . 2-11Name Property . . . . . . . . . . . . . . . . . . . . . . . .
2 Creating a GUI2-18cursor to a specific callback by clicking the function icon on the toolbar, then selecting the callback you want in the pop-up m
Programming the GUI2-19Sharing Data Between CallbacksThis topic describes the process for sharing data between callbacks in a GUI. Subsequent topics,
2 Creating a GUI2-20Note To save any changes that you make to the handles structure, you must use the command guidata(hObject,handles). It is not suf
Programming the GUI2-21% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a futur
2 Creating a GUI2-22The following figure shows how the GUI now looks when it first displays.Adding Code to the CallbacksWhen the GUI is completed and
Programming the GUI2-23Add the code after the comments following the function definition, as shown below:Surf push button callback:% --- Executes on b
2 Creating a GUI2-24Add this code to the Contour push button callback:% Display contour plot of the currently selected datacontour(handles.current_dat
Programming the GUI2-25properties of each component of the GUI. Selecting the name of a component in the list also selects the component in the Layout
2 Creating a GUI2-26Saving and Running a GUIAfter writing the callbacks, you can run the GUI by selecting Run from the Tools menu or clicking the Run
Saving and Running a GUI2-27Note The name of the FIG-file saved by the Layout Editor and the generated M-file must match. See “Renaming GUI Files” if
iiiLayout Editor Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22Layout Editor Context Menus . . . . . . . . . . . . . . .
2 Creating a GUI2-28Try experimenting with this GUI by adding another data set in the opening function, and a push button that displays a plot of the
3Laying Out GUIs and Setting Properties Using GUIDE Templates (p. 3-2) Overview of GUIDE templates — simple GUIs that you modify to create your own G
3 Laying Out GUIs and Setting Properties3-2Using GUIDE TemplatesGUIDE provides several templates, which are simple examples that you can modify to cre
Using GUIDE Templates3-3right pane. Clicking OK opens the GUI template in the Layout Editor. If you select Save on startup as and type in name in the
3 Laying Out GUIs and Setting Properties3-4Select the blank GUI if the other templates are not suitable starting points for the GUI you are creating,
Using GUIDE Templates3-5When a user enters values for the density and volume of an object, and clicks the Calculate button, the GUI calculates the mas
3 Laying Out GUIs and Setting Properties3-6You can select other plots in the pop-up menu. Clicking the Update button displays the currently selected p
Using GUIDE Templates3-7Running the GUI displays the dialog shown in the following figure:The GUI returns the text string Yes or No, depending on whic
3 Laying Out GUIs and Setting Properties3-8To restore access to other MATLAB windows once a button is clicked, add the following command to callbacks
Using the Layout Editor3-9Using the Layout EditorThe Layout Editor enables you to select GUI components from the component palette, at the left side o
iv Contents4Programming GUIsUnderstanding the GUI M-File . . . . . . . . . . . . . . . . . . . . . . . . . 4-2Sharing Data with the Handles Structu
3 Laying Out GUIs and Setting Properties3-10If you want to load an existing GUI for editing, typeguide filename.figor use Open from the File menu on t
Using the Layout Editor3-11After selecting the components for your GUI and placing them in the layout area, you need to set their properties and progr
3 Laying Out GUIs and Setting Properties3-12single-line edit text, Ctl+Enter for a multi-line edit text, or the focus moves away.Static TextStatic tex
Using the Layout Editor3-13Button GroupButton groups are like panels but can be used to manage exclusive selection behavior for radio buttons and togg
3 Laying Out GUIs and Setting Properties3-14 Adding a Component to a Panel or Button GroupTo add a component to a panel or button group, select the
Using the Layout Editor3-15If the component is not entirely contained in the panel or button group, it appears to be clipped in the layout editor.When
3 Laying Out GUIs and Setting Properties3-16You can use the Object Browser to determine the child objects of a panel or button group. “Viewing the Obj
Using the Layout Editor3-17Selecting ComponentsYou can select components in the layout area in the following ways. • Click a single component to selec
3 Laying Out GUIs and Setting Properties3-18panel, or button group from which you move them, even if they move outside its boundaries.Copying, Cutting
Using the Layout Editor3-19• Right-click and drag the component to the desired location. The position of the cursor when you drop the components deter
vInterrupting Executing Callbacks . . . . . . . . . . . . . . . . . . . . . 4-35Controlling Interruptibility . . . . . . . . . . . . . . . . . . .
3 Laying Out GUIs and Setting Properties3-20Replace — writes over the existing file.Append — inserts new callbacks for components added since the last
Using the Layout Editor3-21Note GUIDE automatically saves both the M-file and the FIG-file when you run the GUI.Saving the LayoutOnce you have create
3 Laying Out GUIs and Setting Properties3-224 Save the exported M-file in the Save As dialog. By default, GUIDE gives the exported M-file the name of
Using the Layout Editor3-23Layout Editor Context MenusWhen working in the Layout Editor, you can select an object with the left mouse button and then
3 Laying Out GUIs and Setting Properties3-24Component Context MenusThe following picture shows the context menu associated with user interface control
Selecting GUI Options3-25Selecting GUI OptionsAfter opening a new GUI template in the Layout Editor, but before saving the GUI, you can configure the
3 Laying Out GUIs and Setting Properties3-26Resize BehaviorYou can control whether users can resize the figure window containing your GUI and how MATL
Selecting GUI Options3-27Property Settings. GUIDE sets the following properties to create proportional resizing GUIs:•Units properties of the axes, us
3 Laying Out GUIs and Setting Properties3-28such as plot, that alter the current figure. With the default option, which is Callback (GUI becomes Curre
Selecting GUI Options3-29HandleVisibility — Callback. Setting HandleVisibility to callback causes handles to be visible from within callback routines
vi ContentsA GUI to Set Simulink Model Parameters . . . . . . . . . . . . . . 5-19Techniques Used in This Example . . . . . . . . . . . . . . . .
3 Laying Out GUIs and Setting Properties3-30Generate Callback Function PrototypesWhen you select Generate callback function prototypes in the GUI Opti
Selecting GUI Options3-31function pushbutton1_Callback(hObject, eventdata, handles)Assigning a Callback Property StringWhen you first add a component
3 Laying Out GUIs and Setting Properties3-32GUI Allows Only One Instance to Run (Singleton)This option allows you to select between two behaviors for
Selecting GUI Options3-33Generate FIG-File OnlySelect Generate FIG-file only in the GUI Options dialog if you do not want GUIDE to generate the M-file
3 Laying Out GUIs and Setting Properties3-34Aligning Components in the Layout EditorYou can select and drag any component or group of components that
Aligning Components in the Layout Editor3-35The alignment tool provides two types of alignment operations:•Align — align all selected components to a
3 Laying Out GUIs and Setting Properties3-36All of the align options (vertical top, center, bottom and horizontal left, center, right) place the selec
Aligning Components in the Layout Editor3-37number of other values ranging from 10 to 200 pixels. You can optionally enable snap-to-grid, which causes
3 Laying Out GUIs and Setting Properties3-38Front-to-Back PositioningMATLAB figures maintain separate stacks that control the front-to-back positionin
Aligning Components in the Layout Editor3-39The Layout Editor provides four operations that enable you to control front-to-back positioning:• Bring to
1Getting Started with GUIDEWhat Is GUIDE? (p. 1-2) An introduction to GUIDEStarting GUIDE (p. 1-3) How to start GUIDE and use the Quick Start dialogT
3 Laying Out GUIs and Setting Properties3-40Setting Component Properties — The Property InspectorThe Property Inspector enables you to set the propert
Setting Component Properties — The Property Inspector3-41To change a property, click in the field to the right of the property name, delete its curren
3 Laying Out GUIs and Setting Properties3-42Some Commonly Used PropertiesAs examples, this section describes four important and commonly used properti
Setting Component Properties — The Property Inspector3-43CallbackThe Callback property specifies the callback that is executed in the GUI M-file when
3 Laying Out GUIs and Setting Properties3-44Setting Radio Button PropertiesRadio buttons have two states — selected and not selected. You can query an
Setting Component Properties — The Property Inspector3-45The Value property contains the index into the list of strings that corresponds to the select
3 Laying Out GUIs and Setting Properties3-46Note If you have set units for your GUI to characters, certain combinations of width and height produce a
Setting Component Properties — The Property Inspector3-47The SliderStep property controls the amount the slider Value property changes when you click
3 Laying Out GUIs and Setting Properties3-48Determining Which Item Is Selected. The Value property contains the index of the selected item. For exampl
Setting Component Properties — The Property Inspector3-49• off — The control is disabled and its label (set by the string property) is grayed out.•ina
Kommentare zu diesen Handbüchern