《MATLAB实验报告_4.docx》由会员分享,可在线阅读,更多相关《MATLAB实验报告_4.docx(5页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、MATLAB实验报告四川师范大学MATLAB语言实验报告1系级班年月日实验名称:Intro,Expressions,Commands姓名学号指导老师成绩1ObjectiveTheobjectiveofthislabistofamiliarizeyouwiththeMATLABprogramdevelopmentenvironmentandtodevelopyourfirstprogramsinthisenvironment.2UsingMATLAB2.1StartingMATLABLogontoyourcomputerandstartMATLABbydouble-clickingontheic
2、ononthedesktoporbyusingtheStartProgramsmenu.MATLABDesktopwindowwillappearonthescreen.Thedesktopconsistsofseveralsub-windows.Themostimportantonesare:CommandWindow(ontherightsideoftheDesktop)isusedtodocalculations,entervariablesandrunbuilt-inandyourownfunctions.Workspace(ontheupperleftside)consistsoft
3、hesetofvariables(arrays)createdduringthecurrentMATLABsessionandstoredinmemory.CommandHistory(onthelowerleftside)logscommandsenteredintheCommandWindow.Youcanusethiswindowtoviewpreviouslyrunstatements,andcopyandexecuteselectedstatements.YoucanswitchbetweentheLaunchPadwindowandtheWorkspacewindowusingth
4、emenutabsunderthesub-windowontheupperleftside.Similarly,youcanswitchbetweentheCommandHistoryandCurrentDirectorywindowsusingthemenutabsunderthesub-windowonthelowerleftside.2.2ExecutingCommandsYoucantypeMATLABcommandsatthecommandprompt“ontheCommandWindow.Forexample,youcantypetheformulacos(/6)2sin(3/8)
5、as(cos(pi/6)2)*(sin(3*pi/8)Trythiscommand.Afteryoufinishtyping,pressenter.ThecommandwillbeinterpretedandtheresultwillbedisplayedontheCommandWindow.TrythefollowingbyobservinghowtheWorkspacewindowchanges:a=2;(Makenoteoftheusageof“;)b=3;c=a4?b?5+pi3Youcanseethevariablesa,bandcwiththeirtypesandsizesonth
6、eWorkspacewindow,andcanseethecommandsontheCommandHistorywindow.Spendafewminutestopracticedefiningarrayvariables(i.e.vectorsandmatrices)usingthesquarebracket(“)andcolon(“:)operators,andzeros()andones()functions.ar=12345;br=123;456;cr=1:3:15;?Setdrto?rst3elementsofar.?Setertosecondrowofbr.?Setartodrer
7、.Findthenumberofelementsofar.2.3GettingHelpThereareseveralwaystogethelponcommandsandfunctionsinMATLAB.FirstofallyoucanusetheHelpmenu.Youcanalsousethe“?button.Trytofindinformationontheplotfunctionfromthehelpindex.Alsotrytogetinformationonthesamefunctionusingthehelpcommand(i.e.typehelpplot).Finally,ex
8、perimentwiththelookforcommand.Thiscommandlooksforothercommandsrelatedtoagivenkeyword.2.4SomeUsefulCommandsTrythefollowingcommandsandobservetheirresults:Which:VersionandlocationinfoClear:ClearstheworkspaceClc:Clearsthecommandwindowwho,whos:Listscontentoftheworkspace3ExercisesPleasesolvethefollowingproblemsinMATLAB.Donotforgettokeepadiaryofyourcommandsandtheiroutputs.(1)De?nethevariablesxyandzas7.6,5.5and8.1,respectively,andevaluate:578.422.52?-xyxz此页面能否是列表页或首页?未找到适宜正文内容。