MATLAB Creating Graphical User Interfaces - Cornell University

1y ago
9 Views
2 Downloads
4.69 MB
759 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Noelle Grant
Transcription

MATLAB Creating Graphical User InterfacesR2012a

How to Contact MathWorksWebNewsgroupwww.mathworks.com/contact TS.html Technical service@mathworks.cominfo@mathworks.comProduct enhancement suggestionsBug reportsDocumentation error reportsOrder status, license renewals, passcodesSales, pricing, and general information508-647-7000 (Phone)508-647-7001 (Fax)The MathWorks, Inc.3 Apple Hill DriveNatick, MA 01760-2098For contact information about worldwide offices, see the MathWorks Web site.MATLAB Creating Graphical User Interfaces COPYRIGHT 2000–2012 by The MathWorks, Inc.The software described in this document is furnished under a license agreement. The software may be usedor copied only under the terms of the license agreement. No part of this manual may be photocopied orreproduced in any form without prior written consent from The MathWorks, Inc.FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentationby, for, or through the federal government of the United States. By accepting delivery of the Programor Documentation, the government hereby agrees that this software or documentation qualifies ascommercial computer software or commercial computer software documentation as such terms are usedor defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms andconditions of this Agreement and only those rights specified in this Agreement, shall pertain to and governthe use, modification, reproduction, release, performance, display, and disclosure of the Program andDocumentation by the federal government (or other entity acquiring for or through the federal government)and shall supersede any conflicting contractual terms or conditions. If this License fails to meet thegovernment’s needs or is inconsistent in any respect with federal procurement law, the government agreesto return the Program and Documentation, unused, to The MathWorks, Inc.TrademarksMATLAB and Simulink are registered trademarks of The MathWorks, Inc. Seewww.mathworks.com/trademarks for a list of additional trademarks. Other product or brandnames may be trademarks or registered trademarks of their respective holders.PatentsMathWorks products are protected by one or more U.S. patents. Please seewww.mathworks.com/patents for more information.

Revision HistoryNovember 2000June 2001July 2002June 2004October 2004March 2005September 2005March 2006May 2006September 2006March 2007September 2007March 2008October 2008March 2009September 2009March 2010September 2010April 2011September 2011March lyOnlyOnlyOnlyNew for MATLAB 6.0 (Release 12)Revised for MATLAB 6.1 (Release 12.1)Revised for MATLAB 6.6 (Release 13)Revised for MATLAB 7.0 (Release 14)Revised for MATLAB 7.0.1 (Release 14SP1)Revised for MATLAB 7.0.4 (Release 14SP2)Revised for MATLAB 7.1 (Release 14SP3)Revised for MATLAB 7.2 (Release 2006a)Revised for MATLAB 7.2Revised for MATLAB 7.3 (Release 2006b)Revised for MATLAB 7.4 (Release 2007a)Revised for MATLAB 7.5 (Release 2007b)Revised for MATLAB 7.6 (Release 2008a)Revised for MATLAB 7.7 (Release 2008b)Revised for MATLAB 7.8 (Release 2009a)Revised for MATLAB 7.9 (Release 2009b)Revised for MATLAB 7.10 (Release 2010a)Revised for MATLAB 7.11 (Release 2010b)Revised for MATLAB 7.12 (Release 2011a)Revised for MATLAB 7.13 (Release 2011b)Revised for MATLAB 7.14 (Release 2012a)

ContentsIntroduction to Creating GUIsAbout GUIs in MATLAB Software1.1-2How Does a GUI Work? . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-4Where Do I Start? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-6Ways to Build MATLAB GUIs . . . . . . . . . . . . . . . . . . . . . . .1-8What Is a GUI?How to Create a GUI with GUIDE2Introduction to GUIDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . .What Is GUIDE? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Opening GUIDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Getting Help in GUIDE . . . . . . . . . . . . . . . . . . . . . . . . . . . .Laying Out a GUIDE GUI . . . . . . . . . . . . . . . . . . . . . . . . . .Programming a GUIDE GUI . . . . . . . . . . . . . . . . . . . . . . . .2-22-22-22-42-72-8About the Simple GUIDE GUI Example . . . . . . . . . . . . . .Simple GUIDE GUI Components . . . . . . . . . . . . . . . . . . . . .View Simple GUIDE GUI Layout and Code File . . . . . . . .2-92-92-10Lay Out the Simple GUI in GUIDE . . . . . . . . . . . . . . . . . .Open a New GUI in the GUIDE Layout Editor . . . . . . . . . .Set the GUI Figure Size in GUIDE . . . . . . . . . . . . . . . . . . .Add Components to the Simple GUIDE GUI . . . . . . . . . . .2-112-112-142-15v

Save the GUI Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-25Program the Simple GUIDE GUI . . . . . . . . . . . . . . . . . . . .Add Code to the Simple GUIDE GUI . . . . . . . . . . . . . . . . . .Generate Data to Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Program the Pop-Up Menu . . . . . . . . . . . . . . . . . . . . . . . . . .Program the Push Buttons . . . . . . . . . . . . . . . . . . . . . . . . . .2-282-282-282-312-33Use the Completed Simple GUIDE GUI . . . . . . . . . . . . . .Open and Run the GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-362-36How to Create a Simple GUI Programmatically3viContentsAbout the Simple Programmatic GUI Example . . . . . . .Simple Programmatic GUI Components . . . . . . . . . . . . . . .View Simple Programmatic GUI Code File . . . . . . . . . . . . .Functions for the Simple Programmatic GUI . . . . . . . . . . .3-23-23-33-3Create the Simple Programmatic GUI Code File . . . . . .3-5Lay Out the Simple Programmatic GUI . . . . . . . . . . . . . .Create a Figure for a Programmatic GUI . . . . . . . . . . . . . .Add Components to a Programmatic GUI . . . . . . . . . . . . . .3-73-73-7Code the Simple Programmatic GUI . . . . . . . . . . . . . . . . .Program the Pop-Up Menu . . . . . . . . . . . . . . . . . . . . . . . . . .Program the Push Buttons . . . . . . . . . . . . . . . . . . . . . . . . . .Program Callbacks for the Simple GUI Components . . . . .Initialize the Simple Programmatic GUI . . . . . . . . . . . . . . .The Completed Simple Programmatic GUI Code File . . . .3-113-113-123-123-133-16Use the Completed Simple Programmatic GUI . . . . . . .Open and Run the GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-203-20

Create GUIs with GUIDEWhat Is GUIDE?4GUIDE: Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . .GUI Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .GUI Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-24-24-2GUIDE Tools Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-3GUIDE Preferences and Options5GUIDE Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Set Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Confirmation Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . .Backward Compatibility Preference . . . . . . . . . . . . . . . . . .All Other Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-25-25-25-45-6GUI Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The GUI Options Dialog Box . . . . . . . . . . . . . . . . . . . . . . . .Resize Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Command-Line Accessibility . . . . . . . . . . . . . . . . . . . . . . . .Generate FIG-File and MATLAB File . . . . . . . . . . . . . . . . .Generate FIG-File Only . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-95-95-105-115-125-14Lay Out a GUIDE GUI6Design a GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-2Start GUIDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-4vii

Select a GUI Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Access the Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Template Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-66-66-7Set the GUI Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Maximize the Layout Area . . . . . . . . . . . . . . . . . . . . . . . . . .6-156-18Add Components to the GUI . . . . . . . . . . . . . . . . . . . . . . . .Available Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . .A Working GUI with Many Components . . . . . . . . . . . . . . .Add Components to the GUIDE Layout Area . . . . . . . . . . .Define User Interface Controls . . . . . . . . . . . . . . . . . . . . . . .Define Panels and Button Groups . . . . . . . . . . . . . . . . . . . .Define Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Define Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Add ActiveX Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Copy, Paste, and Arrange Components . . . . . . . . . . . . . . . .Locate and Move Components . . . . . . . . . . . . . . . . . . . . . . .Resize Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . lign Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Align Objects Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Property Inspector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Grid and Rulers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Guide Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-896-896-926-966-96Set Tab Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-98Create Menus in a GUIDE GUI . . . . . . . . . . . . . . . . . . . . . . 6-101Menus for the Menu Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-102Context Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-114Create Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-122Create Toolbars with GUIDE . . . . . . . . . . . . . . . . . . . . . . . . 6-122Editing Tool Icons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-131View the Object Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . 6-136Designing for Cross-Platform Compatibility . . . . . . . . . 6-137Default System Font . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-137viiiContents

Standard Background Color . . . . . . . . . . . . . . . . . . . . . . . . . 6-138Cross-Platform Compatible Units . . . . . . . . . . . . . . . . . . . . 6-139Save and Run a GUIDE GUI7Name a GUI and Its Files . . . . . . . . . . . . . . . . . . . . . . . . . . .The GUI Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .File and GUI Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Rename GUIs and GUI Files . . . . . . . . . . . . . . . . . . . . . . . .7-27-27-37-3Save a GUIDE GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Ways to Save a GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Save a New GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Save an Existing GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Export a GUIDE GUI to a Code File . . . . . . . . . . . . . . . . . .7-47-47-57-87-9Run a GUIDE GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Execute GUI Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .From the GUIDE Layout Editor . . . . . . . . . . . . . . . . . . . . .From the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . .From Any MATLAB Code File . . . . . . . . . . . . . . . . . . . . . . .From a Test Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-107-107-107-117-117-12Programming a GUIDE GUI8Working with Callbacks in GUIDE . . . . . . . . . . . . . . . . . .Programming GUIs Created Using GUIDE . . . . . . . . . . . .What Is a Callback? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Kinds of Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-28-28-28-2Files Generated by GUIDE . . . . . . . . . . . . . . . . . . . . . . . . .Code Files and FIG-Files . . . . . . . . . . . . . . . . . . . . . . . . . . .GUI Code File Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-78-78-8ix

Adding Callback Templates to an Existing GUI CodeFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .About GUIDE-Generated Callbacks . . . . . . . . . . . . . . . . . .8-98-9Default Callback Properties in GUIDE . . . . . . . . . . . . . . .Setting Callback Properties Automatically . . . . . . . . . . . . .Deleting Callbacks from a GUI Code File . . . . . . . . . . . . . .8-118-118-14Customizing Callbacks in GUIDE . . . . . . . . . . . . . . . . . . .GUIDE Callback Templates . . . . . . . . . . . . . . . . . . . . . . . . .Callback Names and Signatures in GUIDE . . . . . . . . . . . .GUIDE Callback Arguments . . . . . . . . . . . . . . . . . . . . . . . .Changing Callbacks Assigned by GUIDE . . . . . . . . . . . . . .8-158-158-168-208-22Initialize a GUIDE GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Opening Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Output Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-258-258-28Add Code for Components in Callbacks . . . . . . . . . . . . . .Push Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Toggle Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Radio Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Check Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Edit Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .List Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Pop-Up Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Button Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .ActiveX Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Menu Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -458-498-59Managing and Sharing Application Data inGUIDE9Ways to Manage Data in a GUIDE GUI . . . . . . . . . . . . . . .xContents9-2

Data Management Mechanism Summary . . . . . . . . . . . . . .Nested Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .UserData Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Application Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .GUI Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Examples of Sharing Data Among a GUI’s Callbacks . . . .9-29-49-59-59-79-10Making Multiple GUIs Work Together . . . . . . . . . . . . . . .Data-Sharing Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . .Example — Manipulating a Modal Dialog Box for UserInput . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Example — Individual GUIDE GUIs Cooperating as IconManipulation Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-219-219-229-30Examples of GUIDE GUIs10GUI with Multiple Axes (GUIDE) . . . . . . . . . . . . . . . . . . . . 10-2About the Multiple Axes Example . . . . . . . . . . . . . . . . . . . . 10-2View and Run the Multiple Axes GUI . . . . . . . . . . . . . . . . . 10-3Design the Multiple Axes GUI . . . . . . . . . . . . . . . . . . . . . . . 10-4Plot Push Button Callback . . . . . . . . . . . . . . . . . . . . . . . . . . 10-8Validate User Input as Numbers . . . . . . . . . . . . . . . . . . . . . 10-11GUI for Animating a 3-D View (GUIDE) . . . . . . . . . . . . . .About the 3-D Animation Example . . . . . . . . . . . . . . . . . . .View and Run the 3-D Globe GUI . . . . . . . . . . . . . . . . . . . .Design the 3-D Globe GUI . . . . . . . . . . . . . . . . . . . . . . . . . .Graphics Techniques Used in the 3-D Globe GUI . . . . . . . .Further Graphic Explorations . . . . . . . . . . . . . . . . . . . . . . .10-1510-1510-1610-1710-2410-29GUI to Interactively Explore Data in a Table(GUIDE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .About the tablestat Example . . . . . . . . . . . . . . . . . . . . . . . .View and Run the tablestat GUI . . . . . . . . . . . . . . . . . . . . .Design the tablestat GUI . . . . . . . . . . . . . . . . . . . . . . . . . . .Extend the tablestat GUI . . . . . . . . . . . . . . . . . . . . . . . . . . .10-3110-3110-3310-3510-52List Box Directory Reader (GUIDE) . . . . . . . . . . . . . . . . . 10-54xi

About the List Box Directory Example . . . . . . . . . . . . . . . . 10-54View and Run the List Box Directory GUI . . . . . . . . . . . . . 10-55Implement the List Box Directory GUI . . . . . . . . . . . . . . . . 10-56xiiContentsAccess Workspace Variables from a List Box(GUIDE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .About the Workspace Variable Example . . . . . . . . . . . . . . .View and Run the Workspace Variable GUI . . . . . . . . . . . .Read Workspace Variables . . . . . . . . . . . . . . . . . . . . . . . . . .Read Selections from List Box . . . . . . . . . . . . . . . . . . . . . . .10-6110-6110-6210-6310-64A GUI to Set Simulink Model Parameters (GUIDE) . . .About the Simulink Model Parameters Example . . . . . . . .View and Run the Simulink Parameters GUI . . . . . . . . . . .How to Use the Simulink Parameters GUI . . . . . . . . . . . . .Run the GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Program the Slider and Edit Text Components . . . . . . . . .Run the Simulation from the GUI . . . . . . . . . . . . . . . . . . . .Remove Results from List Box . . . . . . . . . . . . . . . . . . . . . . .Plot Results Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The GUI Help Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Close the GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The List Box Callback and Create Function . . . . . . . . . . . 810-7810-79An Address Book Reader (GUIDE) . . . . . . . . . . . . . . . . . .About the Address Book Reader Example . . . . . . . . . . . . . .View and Run the Address Book Reader GUI . . . . . . . . . . .Run the Address Book Reader GUI . . . . . . . . . . . . . . . . . . .Load an Address Book Into the Reader . . . . . . . . . . . . . . . .The Contact Name Callback . . . . . . . . . . . . . . . . . . . . . . . . .The Contact Phone Number Callback . . . . . . . . . . . . . . . . .Page Through Address Book — Prev/Next . . . . . . . . . . . . .Save Address Book Changes from the Menu . . . . . . . . . . . .The Create New Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The Address Book Resize Function . . . . . . . . . . . . . . . . . . 410-95Use a Modal Dialog Box to Confirm an Operation(GUIDE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .About the Modal Dialog Example . . . . . . . . . . . . . . . . . . . .View and Run the Modal Dialog Box GUIs . . . . . . . . . . . . .Set Up the Close Confirmation Dialog . . . . . . . . . . . . . . . . .Set Up the GUI with the Close Button . . . . . . . . . . . . . . . .10-9810-9810-9910-10010-101

Run the Close-Confirmation GUI . . . . . . . . . . . . . . . . . . . . . 10-102How the Close-Confirmation GUIs Work . . . . . . . . . . . . . . 10-103Time Data Updates from a GUI (GUIDE) . . . . . . . . . . . . .About the Timer GUI Example . . . . . . . . . . . . . . . . . . . . . .View and Run the GUIDE Timer GUI . . . . . . . . . . . . . . . . .Components Used by the Timer GUI . . . . . . . . . . . . . . . . . .How the GUI Implements the Timer . . . . . . . . . . . . . . . . . .Other Uses for Timers in GUIs . . . . . . . . . . . . . . . . . . . . . .10-10510-10510-10610-10710-10910-112Create GUIs ProgrammaticallyLay Out a Programmatic GUI11Design a Programmatic GUI . . . . . . . . . . . . . . . . . . . . . . . .11-2Create and Run a Programmatic GUI . . . . . . . . . . . . . . . .File Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .File Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Run the GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-411-411-411-5Create Figures for Programmatic GUIs . . . . . . . . . . . . . .11-6Add Components to a Programmatic GUI . . . . . . . . . . . .Types of GUI Components . . . . . . . . . . . . . . . . . . . . . . . . . .Add User Interface Controls to a Programmatic GUI . . . . .Add Panels and Button Groups . . . . . . . . . . . . . . . . . . . . . .Add Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Add ActiveX Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-911-911-1311-3211-3811-41Compose and Code GUIs with Interactive Tools . . . . . .Set Positions of Components Interactively . . . . . . . . . . . . .Align Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Set Colors Interactively . . . . . . . . . . . . . . . . . . . . . . . . . . . .Set Font Characteristics Interactively . . . . . . . . . . . . . . . . .Generate Code to Set Component Properties . . . . . . . . . . .11-4211-4311-5311-6011-6211-64xiii

Set Tab Order in a Programmatic GUI . . . . . . . . . . . . . . .How Tabbing Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Default Tab Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Change the Tab Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-7011-7011-7011-73Create Menus for a Programmatic GUI . . . . . . . . . . . . . . 11-75Add Menu Bar Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-75Add Context Menus to a Programmatic GUI . . . . . . . . . . . 11-81Create Toolbars for Programmatic GUIs . . . . . . . . . . . . .Use the uitoolbar Function . . . . . . . . . . . . . . . . . . . . . . . . . .Commonly Used Properties . . . . . . . . . . . . . . . . . . . . . . . . .Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Display and Modify the Standard Toolbar . . . . . . . . . . . . .11-8811-8811-8811-8911-92Design Programmatic GUIs for Cross-PlatformCompatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Default System Font . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Standard Background Color . . . . . . . . . . . . . . . . . . . . . . . . .Cross-Platform Compatible Units . . . . . . . . . . . . . . . . . . . .11-9411-9411-9511-96Code a Programmatic GUI12Organize a Programmatic GUI File . . . . . . . . . . . . . . . . . .12-2Initialize a Programmatic GUI . . . . . . . . . . . . . . . . . . . . . .Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-312-4Write Code for Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-7What Is a Callback? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-7Kinds of Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-8Specify Callbacks in Function Calls . . . . . . . . . . . . . . . . . . . 12-11Examples: Program GUI Components . . . . . . . . . . . . . . .Program User Interface Controls . . . . . . . . . . . . . . . . . . . . .Program Panels and Button Groups . . . . . . . . . . . . . . . . . .Program Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xivContents12-2012-2012-2812-31

Program ActiveX Controls . . . . . . . . . . . . . . . . . . . . . . . . . . 12-34Program Menu Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-34Program Toolbar Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-37Manage Application-Defined Data13Ways to Manage Data in a Programmatic GUI . . . . . . . .Data Management Mechanism Summary . . . . . . . . . . . . . .Nested Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .UserData Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Application Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .GUI Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-213-213-413-513-613-8Share Data Among a GUI’s Callbacks . . . . . . . . . . . . . . . .Share Data with Nested Functions . . . . . . . . . . . . . . . . . . .Share Data with UserData . . . . . . . . . . . . . . . . . . . . . . . . . .Share Data with Application Data . . . . . . . . . . . . . . . . . . . .Share Data with GUI Data . . . . . . . . . . . . . . . . . . . . . . . . . .13-1113-1113-1513-1813-21Manage Callback Execution14Callback Sequencing and Interruption . . . . . . . . . . . . . . 14-2Control Callback Execution and Interruption . . . . . . . . . . . 14-2Control Program Execution Using Timer Objects . . . . . . . . 14-11Examples of GUIs Created Programmatically15Techniques Explored by Programmatic GUIExamples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15-2xv

GUI with Axes, Menu, and Toolbar . . . . . . . . . . . . . . . . . . 15-4About the Axes, Menu, and Toolbar Example . . . . . . . . . . . 15-4View and Run the AxesMenuToolbar Code . . . . . . . . . . . . . 15-6Generate the Graphing Commands and Data . . . . . . . . . . . 15-7Create the GUI and Its Components . . . . . . . . . . . . . . . . . . 15-8Initialize the GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-13Define the Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-14Helper Function: Plot the Plot Types . . . . . . . . . . . . . . . . . 15-18xviContentsGUI that Displays and Graphs Tabular Data . . . . . . . . .About the tableplot Example . . . . . . . . . . . . . . . . . . . . . . . .View and Run the tableplot Code . . . . . . . . . . . . . . . . . . . . .Set Up and Interact with the uitable . . . . . . . . . . . . . . . . . .Subfunction Summary for tableplot . . . . . . . . . . . . . . . . . . .Further Explorations with tableplot . . . . . . . . . . . . . . . . . .15-1915-1915-2315-2415-3015-30A GUI That Manages List Data . . . . . . . . . . . . . . . . . . . . . .About the List Master Example . . . . . . . . . . . . . . . . . . . . . .View and Run the List Master Code . . . . . . . . . . . . . . . . . .Use List Master . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Program List Master . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Add an “Import from File” Option to List Master . . . . . . . .Add a “Rename List” Option to List Master . . . . . . . . . . . .15-3315-3315-3615-3715-4215-5015-50Color Palette . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .About the Color Palette Example . . . . . . . . . . . . . . . . . . . . .Techniques Used in the Color Palette Example . . . . . . . . .View and Run the Color Palette Code . . . . . . . . . . . . . . . . .Subfunction Summary for Color Palette . . . . . . . . . . . . . . .Code File Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . .GUI Programming Techniques . . . . . . . . . . . . . . . . . . . . . . .15-5115-5115-5515-5515-5615-5715-58Icon Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .About the Icon Editor Example . . . . . . . . . . . . . . . . . . . . . .View and Run the Icon Editor Code . . . . . . . . . . . . . . . . . . .Subfunction Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Code File Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . .GUI Programming Techniques . . . . . . . . . . . . . . . . . . . . . . .15-6315-6315-6515-6815-7015-70

ExamplesASimple Examples (GUIDE) . . . . . . . . . . . . . . . . . . . . . . . . . .A-2Simple Examples (Programmatic) . . . . . . . . . . . . . . . . . . .A-3Application Examples (GUIDE) . . . . . . . . . . . . . . . . . . . . .A-4Programming GUI Components (GUIDE) . . . . . . . . . . . .A-5Application-Defined Data (GUIDE) . . . . . . . . . . . . . . . . . .A-6GUI Layout (Programmatic) . . . . . . . . . . . . . . . . . . . . . . . .A-7Programming GUI Components (Programmatic) . . . . .A-8Application-Defined Data (Programmatic) . . . . . . . . . . .A-9Application Examples (Programmatic) . . . . . . . . . . . . . .A-10Indexxvii

xviiiContents

Introduction to Creating GUIsChapter 1, About GUIs inMATLAB Software (p. 1-1)Explains what a GUI is, howa GUI works, and how to getstarted creating a GUI.Chapter 2, How to Create a GUIwith GUIDE (p. 2-1)Steps you through

Programming a GUIDE GUI.2-8 About the Simple GUIDE GUI Example.2-9 Simple GUIDE GUI Components.2-9 View Simple GUIDE GUI Layout and Code File . Designing for Cross-Platform Compatibility.6-137 Default System Font.6-137 viii Contents. Standard Background .

Related Documents:

MATLAB tutorial . School of Engineering . Brown University . To prepare for HW1, do sections 1-11.6 – you can do the rest later as needed . 1. What is MATLAB 2. Starting MATLAB 3. Basic MATLAB windows 4. Using the MATLAB command window 5. MATLAB help 6. MATLAB ‘Live Scripts’ (for algebra, plotting, calculus, and solving differential .

19 MATLAB Excel Add-in Hadoop MATLAB Compiler Standalone Application MATLAB deployment targets MATLAB Compiler enables sharing MATLAB programs without integration programming MATLAB Compiler SDK provides implementation and platform flexibility for software developers MATLAB Production Server provides the most efficient development path for secure and scalable web and enterprise applications

MATLAB tutorial . School of Engineering . Brown University . To prepare for HW1, do sections 1-11.6 – you can do the rest later as needed . 1. What is MATLAB 2. Starting MATLAB 3. Basic MATLAB windows 4. Using the MATLAB command window 5. MATLAB help 6. MATLAB ‘Live Scripts’ (for

3. MATLAB script files 4. MATLAB arrays 5. MATLAB two‐dimensional and three‐dimensional plots 6. MATLAB used‐defined functions I 7. MATLAB relational operators, conditional statements, and selection structures I 8. MATLAB relational operators, conditional statements, and selection structures II 9. MATLAB loops 10. Summary

user and the application. This kind of environments are known as a Graphical User Interfaces (GUI). Graphical interfaces are present in various types of devices and platforms, such as web form or a smartphone application. Most, if not all, graphical user interface based applications use an event management based architecture. Applications

foundation of basic MATLAB applications in engineering problem solving, the book provides opportunities to explore advanced topics in application of MATLAB as a tool. An introduction to MATLAB basics is presented in Chapter 1. Chapter 1 also presents MATLAB commands. MATLAB is considered as the software of choice. MATLAB can be used .

I. Introduction to Programming Using MATLAB Chapter 1: Introduction to MATLAB 1.1 Getting into MATLAB 1.2 The MATLAB Desktop Environment 1.3 Variables and Assignment Statements 1.4 Expressions 1.5 Characters and Encoding 1.6 Vectors and Matrices Chapter 2: Introduction to MATLAB Programming 2.1 Algorithms 2.2 MATLAB Scripts 2.3 Input and Output

Compiler MATLAB Production Server Standalone Application MATLAB Compiler SDK Apps Files Custom Toolbox Python With MATLAB Users With People Who Do Not Have MATLAB.lib/.dll .exe . Pricing Risk Analytics Portfolio Optimization MATLAB Production Server MATLAB CompilerSDK Web Application