收藏 分享(赏)

matlab 2013 官方教程(GUI-分册).pdf

上传人:HR专家 文档编号:6226297 上传时间:2019-04-03 格式:PDF 页数:711 大小:4.21MB
下载 相关 举报
matlab 2013 官方教程(GUI-分册).pdf_第1页
第1页 / 共711页
matlab 2013 官方教程(GUI-分册).pdf_第2页
第2页 / 共711页
matlab 2013 官方教程(GUI-分册).pdf_第3页
第3页 / 共711页
matlab 2013 官方教程(GUI-分册).pdf_第4页
第4页 / 共711页
matlab 2013 官方教程(GUI-分册).pdf_第5页
第5页 / 共711页
点击查看更多>>
资源描述

1、MATLAB Creating Graphical User Interfaces R2013aHow to Contact MathWorks Web comp.soft-sys.matlab Newsgroup Technical Support Product enhancementsuggestions Bug reports Documentation error reports Orderstatus,licenserenewals,passcodes Sales,pricing,andgeneralinformation 508-647-7000(Phone) 50

2、8-647-7001(Fax) TheMathWorks,Inc. 3 Apple Hill Drive Natick, MA 01760-2098 Forcontactinformationaboutworldwideoffices,seetheMathWorksWebsite. MATLAB Creating Graphical User Interfaces COPYRIGHT 20002013 by The MathWorks, Inc. Thesoftwaredescribedinthisdocumentisfurnishedunderalicenseagreement. Theso

3、ftwaremaybeused or copied only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form without prior written consent from The MathWorks, Inc. FEDERAL ACQUISITION: Thisprovision applies to all acquisitions ofthe Programand Documentation by, for, o

4、r through the federal government of the United States. By accepting delivery of the Program or Documentation, the government hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer software documentation assuch terms are used or defined in F

5、AR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and conditions of this Agreement and onlythoserights specified inthis Agreement,shall pertain to andgovern theuse,modification,reproduction,release,performance,display,anddisclosureoftheProgramand Documentationbythefederalg

6、overnment(orotherentityacquiringfororthroughthefederalgovernment) and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the governmentsneedsorisinconsistentinanyrespectwithfederalprocurementlaw,thegovernmentagrees to return the Program and Documentation,

7、unused, to The MathWorks, Inc. Trademarks MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See for a list of additional trademarks. Other product or brand namesmay be trademarks orregisteredtrademarksoftheir respectiveholders. Patents MathWorks products are protected by one or m

8、ore U.S. patents. Please see for more information.Revision History November 2000 Online Only New for MATLAB 6.0 (Release 12) June 2001 Online Only Revised for MATLAB 6.1 (Release 12.1) July 2002 Online Only Revised for MATLAB 6.6 (Release 13) June 2004 Online Only Revised for MATLAB 7.0 (Release 14

9、) October 2004 Online Only Revised for MATLAB 7.0.1 (Release14SP1) March 2005 Online Only Revisedfor MATLAB 7.0.4 (Release 14SP2) September 2005 Online Only Revised for MATLAB 7.1 (Release 14SP3) March 2006 Online Only Revised for MATLAB 7.2 (Release 2006a) May 2006 Online Only Revised for MATLAB 7.

10、2 September 2006 Online Only Revised for MATLAB 7.3 (Release 2006b) March 2007 Online Only Revised for MATLAB 7.4 (Release 2007a) September 2007 Online Only Revised for MATLAB 7.5 (Release 2007b) March 2008 Online Only Revised for MATLAB 7.6 (Release 2008a) October 2008 Online Only Revised for MATLA

11、B 7.7 (Release 2008b) March 2009 Online Only Revised for MATLAB 7.8 (Release 2009a) September 2009 Online Only Revised for MATLAB 7.9 (Release 2009b) March 2010 Online Only Revised for MATLAB 7.10 (Release 2010a) September 2010 Online Only Revised for MATLAB 7.11 (Release 2010b) April 2011 Online On

12、ly Revised for MATLAB 7.12 (Release 2011a) September 2011 Online Only Revised for MATLAB 7.13 (Release 2011b) March 2012 Online Only Revised for MATLAB 7.14 (Release 2012a) September 2012 Online Only Revised for MATLAB 8.0 (Release 2012b) March 2013 Online Only Revised for MATLAB 8.1 (Release 2013a)

13、Contents IntroductiontoCreatingGUIs AboutGUIsinMATLABSoftware 1 WhatIsaGUI? 1-2 HowDoesaGUIWork? . 1-4 WhereDoIStart? 1-6 WaystoBuildMATLABGUIs . 1-8 HowtoCreateaGUIwithGUIDE 2 IntroductiontoGUIDE . 2-2 WhatIsGUIDE? 2-2 OpeningGUIDE 2-2 GettingHelpinGUIDE 2-4 LayingOutaGUIDEGUI 2-5 ProgrammingaGUIDE

14、GUI 2-5 AbouttheSimpleGUIDEGUI . 2-6 LayOuttheSimpleGUIinGUIDE 2-8 OpenaNewGUIintheGUIDELayoutEditor 2-8 SettheGUIFigureSizeinGUIDE . 2-11 AddComponentstotheSimpleGUIDEGUI . 2-12 SavetheGUILayout . 2-22 vCodetheSimpleGUIDEGUIBehavior 2-24 AddCodetotheSimpleGUIDEGUI 2-24 GenerateDatatoPlot 2-24 CodeP

15、op-UpMenuBehavior 2-26 CodePushButtonBehavior . 2-28 OpenandRuntheSimpleGUIDEGUI . 2-31 HowtoCreateaSimpleGUIProgrammatically 3 AbouttheSimpleProgrammaticGUI 3-2 CreatetheSimpleProgrammaticGUICodeFile 3-4 LayOuttheSimpleProgrammaticGUI 3-6 CreateaFigureforaProgrammaticGUI 3-6 AddComponentstoaProgram

16、maticGUI 3-6 CodetheSimpleProgrammaticGUI . 3-10 ProgramthePop-UpMenu 3-10 ProgramthePushButtons 3-11 ProgramCallbacksfortheSimpleGUIComponents . 3-11 InitializetheSimpleProgrammaticGUI . 3-12 TheCompletedSimpleProgrammaticGUICodeFile 3-15 UsetheCompletedSimpleProgrammaticGUI . 3-19 OpenandRuntheGUI

17、 . 3-19 vi ContentsCreateGUIs withGUIDE What Is GUIDE? 4 GUIDE:GettingStarted 4-2 GUILayout 4-2 GUIProgramming . 4-2 GUIDEToolsSummary . 4-3 GUIDEPreferencesandOptions 5 GUIDEPreferences 5-2 SetPreferences . 5-2 ConfirmationPreferences . 5-2 BackwardCompatibilityPreference 5-4 AllOtherPreferences 5-

18、6 GUIOptions . 5-9 TheGUIOptionsDialogBox 5-9 ResizeBehavior . 5-10 Command-LineAccessibility 5-11 GenerateFIG-FileandMATLABFile . 5-12 GenerateFIG-FileOnly 5-15 LayOutaGUIDEGUI 6 DesignaGUI 6-2 StartGUIDE 6-4 viiSelectaGUITemplate . 6-5 AccesstheTemplates 6-5 TemplateDescriptions . 6-6 SettheGUISiz

19、e . 6-14 MaximizetheLayoutArea 6-17 AddComponentstotheGUI 6-18 AvailableComponents . 6-19 AWorkingGUIwithManyComponents . 6-22 AddComponentstotheGUIDELayoutArea . 6-30 UserInterfaceControls . 6-37 PanelsandButtonGroups 6-55 Axes 6-61 Table . 6-65 ActiveXComponent 6-76 Copy,Paste,andArrangeComponents

20、 6-78 LocateandMoveComponents . 6-82 ResizeComponents 6-85 AlignComponents . 6-88 AlignObjectsTool . 6-88 PropertyInspector . 6-91 GridandRulers . 6-95 Guide Lines 6-95 SetTabOrder . 6-97 CreateMenusinaGUIDEGUI 6-100 MenusfortheMenuBar 6-101 ContextMenus . 6-112 Toolbar . 6-120 CreateToolbarswithGUI

21、DE 6-120 EditingToolIcons . 6-129 ViewtheObjectHierarchy . 6-134 DesigningforCross-PlatformCompatibility . 6-135 DefaultSystemFont . 6-135 viii ContentsStandardBackgroundColor . 6-136 Cross-PlatformCompatibleUnits 6-137 Saveand RunaGUIDEGUI 7 NameaGUIandItsFiles . 7-2 TheGUIFiles 7-2 FileandGUINames

22、 . 7-3 RenameGUIsandGUIFiles 7-3 SaveaGUIDEGUI . 7-4 WaystoSaveaGUI . 7-4 SaveaNewGUI 7-5 SaveanExistingGUI 7-8 ExportaGUIDEGUItoaCodeFile 7-9 RunaGUIDEGUI . 7-10 ExecuteGUICode . 7-10 FromtheGUIDELayoutEditor . 7-10 FromtheCommandLine . 7-11 FromAnyMATLABCodeFile . 7-11 FromaTestScript 7-12 Program

23、mingaGUIDEGUI 8 WorkingwithCallbacksinGUIDE 8-2 ProgrammingGUIsCreatedUsingGUIDE 8-2 WhatIsaCallback? . 8-2 KindsofCallbacks . 8-2 FilesGeneratedbyGUIDE . 8-7 CodeFilesandFIG-Files . 8-7 GUICodeFileStructure 8-8 ixAdding Callback Templates to an Existing GUI Code File . 8-9 AboutGUIDE-GeneratedCallb

24、acks 8-9 DefaultCallbackPropertiesinGUIDE . 8-11 SettingCallbackPropertiesAutomatically . 8-11 DeletingCallbacksfromaGUICodeFile 8-15 CustomizingCallbacksinGUIDE . 8-16 GUIDECallbackTemplates . 8-16 CallbackNamesandSignaturesinGUIDE 8-17 GUIDECallbackArguments 8-21 ChangingCallbacksAssignedbyGUIDE 8

25、-23 InitializeaGUIDEGUI . 8-26 OpeningFunction . 8-26 OutputFunction 8-29 AddCodeforComponentsinCallbacks 8-31 PushButton 8-31 ToggleButton 8-32 RadioButton . 8-33 CheckBox . 8-34 EditText 8-34 Table . 8-36 Slider . 8-37 ListBox . 8-37 Pop-UpMenu . 8-38 Panel . 8-39 ButtonGroup . 8-43 Axes 8-46 Acti

26、veXControl . 8-50 MenuItem . 8-60 ExamplesofGUIDEGUIs . 8-64 x ContentsManaging and Sharing Application Data in GUIDE 9 DataManagementinaGUIDEGUI 9-2 DataManagementMechanism Summary 9-2 NestedFunctions . 9-4 UserDataProperty 9-4 Application Data 9-5 GUIData 9-7 ExamplesofSharingDataAmongaGUIsCallbac

27、ks 9-10 MakingMultipleGUIsWorkTogether . 9-21 Data-SharingTechniques . 9-21 Example Manipulating a Modal Dialog Box for User Input . 9-22 Example Individual GUIDE GUIs Cooperating as Icon ManipulationTools 9-30 Examples of GUIDE GUIs 10 ModalDialogBox(GUIDE) . 10-2 AbouttheExample 10-2 SetUptheClose

28、ConfirmationDialogBox . 10-2 SetUpaGUIwithaCloseButton 10-3 RuntheCloseConfirmationGUI. 10-5 HowtheCloseConfirmationGUIsWork . 10-5 GUI for Manipulating Data That Persists Across MATLABSessions(GUIDE) . 10-7 AbouttheExample 10-7 CallingSyntax 10-8 MAT-fileValidation . 10-9 GUIBehavior 10-11 OverallG

29、UICharacteristics . 10-18 xiGUIThatAcceptsInputDataandPlotsinMultipleAxes (GUIDE) 10-23 AbouttheExample 10-23 MultipleAxesGUI Design 10-25 ValidateGUIInputasNumbers . 10-27 PlotPushButtonBehavior 10-31 GUIforPresentingDatainMultiple,Synchronized Displays(GUIDE) 10-35 AboutMultiple,SynchronizedDispla

30、ysExample 10-35 RecreatetheGUI 10-37 InteractiveListBox(GUIDE) . 10-53 AbouttheExample 10-53 ImplementtheListBoxGUI 10-54 GUIforPlottingWorkspaceVariables(GUIDE) 10-60 AbouttheExample 10-60 ReadWorkspaceVariables 10-61 ReadSelectionsfromListBox . 10-62 GUItoSetSimulinkModelParameters(GUIDE) . 10-65

31、AbouttheExample 10-65 HowtoUsetheSimulinkParametersGUI. 10-66 RuntheGUI . 10-68 ProgramtheSliderandEditTextComponents . 10-69 RuntheSimulationfromtheGUI 10-71 RemoveResultsfromListBox . 10-73 PlotResultsData . 10-74 TheGUIHelpButton 10-76 ClosetheGUI 10-76 TheListBoxCallbackandCreateFunction 10-77 G

32、UI for Interactive Data Exploration via Graphics AnimationControlledbySliders(GUIDE) . 10-79 AbouttheExample 10-79 Designthe3-DGlobeGUI 10-80 GraphicsTechniquesUsedinthe3-DGlobeGUI 10-86 GUIDataDisplaythatRefreshesatSetTimeIntervals (GUIDE) 10-91 xii ContentsAbouttheExample 10-91 HowtheGUIImplements

33、theTimer 10-93 CreateGUIsProgrammatically Lay Out a Programmatic GUI 11 DesignaProgrammaticGUI 11-2 CreateandRunaProgrammaticGUI 11-4 FileOrganization . 11-4 FileTemplate 11-4 RuntheGUI . 11-5 CreateFiguresforProgrammaticGUIs 11-6 AddComponentstoaProgrammaticGUI 11-9 TypesofGUIComponents 11-9 AddUse

34、rInterfaceControlstoaProgrammaticGUI . 11-13 AddPanelsandButtonGroups 11-32 AddAxes 11-38 AddActiveXControls 11-41 ComposeandCodeGUIswithInteractiveTools 11-42 SetPositionsofComponentsInteractively . 11-43 AlignComponents . 11-53 SetColorsInteractively 11-60 SetFontCharacteristicsInteractively . 11-

35、62 SetTabOrderinaProgrammaticGUI . 11-65 HowTabbingWorks . 11-65 DefaultTabOrder . 11-65 ChangetheTabOrder . 11-68 CreateMenusforaProgrammaticGUI 11-70 AddMenuBarMenus 11-70 xiiiAddContextMenustoaProgrammaticGUI . 11-76 CreateToolbarsforProgrammaticGUIs . 11-83 UsetheuitoolbarFunction 11-83 Commonly

36、UsedProperties . 11-83 Toolbars . 11-84 DisplayandModifytheStandardToolbar . 11-87 Design Programmatic GUIs for Cross-Platform Compatibility . 11-89 DefaultSystemFont . 11-89 StandardBackgroundColor . 11-90 Cross-PlatformCompatibleUnits 11-91 Code a ProgrammaticGUI 12 OrganizeaProgrammaticGUIFile 12

37、-2 InitializeaProgrammaticGUI 12-3 Examples 12-4 WriteCodeforCallbacks . 12-7 WhatIsaCallback? . 12-7 KindsofCallbacks . 12-8 SpecifyCallbacksinFunctionCalls . 12-11 Examples: ProgramGUIComponents . 12-20 ProgramUserInterfaceControls . 12-20 ProgramPanelsandButtonGroups 12-28 ProgramAxes 12-31 Progr

38、amActiveXControls 12-34 ProgramMenuItems 12-34 ProgramToolbarTools . 12-37 ExamplesofProgrammaticGUIs 12-43 xiv ContentsManageApplication-DefinedData 13 DataManagementinaProgrammaticGUI . 13-2 DataManagementMechanism Summary 13-2 NestedFunctions . 13-4 UserDataProperty 13-5 Application Data 13-6 GUI

39、Data 13-8 ShareDataAmongaGUIsCallbacks 13-11 ShareDatawithNestedFunctions . 13-11 ShareDatawithUserData 13-15 ShareDatawithApplicationData 13-18 ShareDatawithGUIData 13-20 ManageCallbackExecution 14 CallbackSequencingandInterruption 14-2 ControlCallbackExecutionandInterruption . 14-2 ControlProgramE

40、xecutionUsingTimerObjects 14-11 ExamplesofGUIsCreatedProgrammatically 15 GUIwithAxes,Menu,andToolbar 15-2 TechniquesIllustratedintheExample 15-2 AbouttheExample 15-3 ViewtheExampleCode 15-4 GeneratetheGraphingCommandsandData . 15-4 CreatetheGUIandItsComponents 15-5 InitializetheGUI . 15-10 Definethe

41、Callbacks . 15-11 HelperFunction: PlotthePlotTypes . 15-15 xvGUIforPresentingDatainMultiple,Synchronized Displays 15-16 TechniquesIllustratedintheExample 15-16 AbouttheExample 15-16 ViewtheExampleCode 15-18 SetUpandInteractwiththeuitable 15-18 LocalFunctionSummaryfortheExample . 15-23 GUI for Manipu

42、lating Data that Persists Across MATLABSessions . 15-25 TechniquesIllustratedintheExample 15-25 AbouttheExample 15-26 ViewtheExampleCode 15-27 UsetheGUI 15-28 ProgramListMaster . 15-33 Addan“ImportfromFile”OptiontoListMaster 15-41 Adda“RenameList”OptiontoListMaster 15-41 GUIThatAcceptsProperty-Value

43、Pairs . 15-42 AbouttheExample 15-42 CopyandViewtheColorPaletteCode 15-45 LocalFunctionSummaryforColorPalette . 15-45 CodeFileOrganization . 15-46 GUIProgrammingTechniques . 15-47 SummaryofCallbacks . 15-49 Apps 16 FindApps . 16-2 ViewAppFileList . 16-3 BeforeInstalling 16-3 AfterInstalling . 16-3 Ru

44、n,Uninstall,Reinstall,andInstallApps . 16-5 RunApp . 16-5 InstallorReinstallApp . 16-5 UninstallApp 16-6 xvi ContentsInstallAppsinaSharedNetworkLocation 16-7 ChangeAppsInstallationFolder 16-8 Packaging GUIs as Apps 17 AppsOverview 17-2 WhatIsanApp? 17-2 WheretoGetApps 17-2 WhyCreateanApp? . 17-3 Bes

45、tPracticesandRequirementsforCreatinganApp . 17-4 PackageApps . 17-5 ModifyApps . 17-7 ShareApps 17-8 MATLABAppInstallerFilemlappinstall 17-9 DependencyAnalysis 17-10 Index xviixviii ContentsIntroduction to Creating GUIs Chapter 1, About GUIs in MATLAB Software (p. 1-1) Explains what a GUI is, how aG

46、UIworks,andhowtoget started creating a GUI. Chapter 2, How to Create a GUI with GUIDE (p. 2-1) Steps you through the process of creating a simple GUI using GUIDE. Chapter 3, How to Create a Simple GUI Programmatically (p. 3-1) Steps you through the process of creating a simple GUI programmatically.1

47、 About GUIs in MATLAB Software “What Is a GUI?” on page 1-2 “How Does a GUI Work?” on page 1-4 “Where Do I Start?” on page 1-6 “Ways to Build MATLAB GUIs” on page 1-81 About GUIs in MATLAB Software What Is a GUI? A graphical user interface (GUI) is a graphical display in one or more windowscontainin

48、gcontrols,calledcomponents,thatenableausertoperform interactive tasks. The user of the GUI does not have to create a script or type commandsatthecommandline toaccomplish the tasks. Unlikecoding programs to accomplish tasks, the user of a GUI need not understand the details of how the tasks are perfo

49、rmed. GUI components can include menus, toolbars, push buttons, radio buttons, list boxes, and slidersjust to name a few. GUIs created using MATLAB tools can also perform any type of computation, read and write data files, communicatewithotherGUIs,anddisplaydataastablesorasplots. The following figure illustrates a simple GUI that you can easily build yourself. The GUI con

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 实用文档 > 简明教程

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报