科学计算科学计算 (49).pdf

上传人:奉*** 文档编号:67731073 上传时间:2022-12-26 格式:PDF 页数:20 大小:1.70MB
返回 下载 相关 举报
科学计算科学计算 (49).pdf_第1页
第1页 / 共20页
科学计算科学计算 (49).pdf_第2页
第2页 / 共20页
点击查看更多>>
资源描述

《科学计算科学计算 (49).pdf》由会员分享,可在线阅读,更多相关《科学计算科学计算 (49).pdf(20页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、8.5 App Development Using App Designer8.5 App Development Using App DesignerApp is the short for application program.Here App means MATLABprograms with a graphical user interface(GUI).App DesignerApp ComponentsApp1 1App DesignerApp DesignerApp Designer is a rich development environment for building

2、apps.In addition to standard components,App Designer offers gauges,lamps,knobs,and switches for inclusion in your app.App Designer generates code that is structured to facilitate app development and data sharing across the app.(1)Open App DesignerAt the MATLAB command prompt,type appdesigner.On the

3、MATLAB Home tab,select New App App Designer.(2)App Designer QuickAccess Toolbar(QAT)RibbonDesign Area1 1App DesignerApp Designer(3)CanvasDesign View:to edit the user interfaceCode View:for editing,debugging,and analyzing code1 1App DesignerApp Designer(3)CanvasDesign view Component Library Component

4、 BrowserInspector tab is used to view or set properties that control the appearanceof the component.1 1App DesignerApp Designer(3)CanvasCode View Code Browser APP Layout Component Browser Inspector tab is used to view or set properties that control the behavior of the component.1 1App DesignerApp De

5、signerCommon ComponentsContainersInstrumentation Components2 2Components in App Components in App DesignerDesignerSaveAppFile:AppDemo.mlappAdd ComponentsKnobDiscre KnobButtonButtonGroup and Radio ButtonUIAxesExample 1:Create an App user interface,.The interface includes 1 axes,2 knobs,2 buttons and

6、1 button group.(1)Start App Designer.(2)Set properties of componentSet Knob propertiesValue,Maximum,MinimumTicks IntervalLabel under the KnobLabel text under the DiscreteKnobSet ButtonGroup propertiesTitle of ButtonGroupText of RadioButtonsLabel of Buttons2 2Components in App Components in App Desig

7、nerDesigner2 2Components in App Components in App DesignerDesigner(2)Set properties of component2 2Components in App Components in App DesignerDesigner(2)Set properties of componentTurn to Code View.In the Component Browser,Select the DiscreteKnob.Then in the Property Inspector,set Value,Maximum,Min

8、imum of the DiscreteKnob.(3)Write CallbacksIn code Code View,in the Editor tab,click Callbacks.Or in the Code Browser on theCallbacks tab,click the button.Right-click a component in the canvas,Component Browser,or App Layout pane,andselect Callbacks Add(callback property)callback.2 2Components in Ap

9、p Components in App DesignerDesignerApp Designer uses object-oriented programming to create an app.Objects declaration,functions,properties and shared data are all packaged in a class.An MLApp file is defined as a class.(1)Basic framework of MATLAB classProperties block is the properties definition,

10、mainly including properties declaration.Methods block is the methods definition,including several functions.The callback functionhas only one argument,App,which is the UI handle.It stores data of each member in theinterface.3 3Programming in Programming in App DesignerApp Designer(1)Basic framework

11、of MATLAB classclassdef ClassName matlab.apps.AppBaseproperties(Access=public)endmethods(Access=private)function Function1(app)endfunction Function2(app)endendend3 3Programming in Programming in App DesignerApp DesignerAccessing data and calling functions are called access object members.(2)Permissi

12、ons for accessThe public members can be used to share data with other classes of the app.The private members can be accessed in the class only,including:Property declaration The startupFcn function The createComponents function Other callback function3 3Programming in Programming in App DesignerApp

13、DesignerExample 2:Perform the drawing function in Example 1.Click the Draw button,to plot the sine curve with the Value of the Frequency Multiplier Knob and the Value of the Phase Angle Knob.Click the Clear button to clear the graph in the axes.Select Add ButtonPushedFcn callback item from the Draw

14、button right-click context menu.function Draw_Plot(app)f=eval(app.DiscreteKnob.Value);%Get Value of DiscreteKnobtheta=app.Knob.Value/180*pi;%Get Value of Knobx=linspace(0,2*pi,60);if app.RadioButton.Value=1 y=sin(f*x+theta);elsey=cos(f*x+theta);End%The first argument of th plot function must be a UI

15、Axes%LineWidth of Lines in App must 0.4plot(app.UIAxes,x,y,LineWidth,0.2);endCode behavior of the app in the methods blockCallback function of Draw buttonfunction Clear_Axes(app)cla(app.UIAxes)endCode behavior of the app in the methods blockCallback function of Clear button(3)Run the appOn the file

16、in App Designer,click Run on the toolstrip,or press F5 key.Double-Click the MLApp file in Current Folder.Type the MLApp file name at the MATLAB command prompt.3 3Programming in Programming in App DesignerApp Designer(4)Package the appClick the Package App button in the toolbar on the Designer tab of App Designer.It will open the Package App dialog box.3 3Programming in Programming in App DesignerApp Designer

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 大学资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁