Danh mục

Lecture note Data visualization - Chapter 20

Số trang: 40      Loại file: pptx      Dung lượng: 3.66 MB      Lượt xem: 4      Lượt tải: 0    
Xem trước 4 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

This chapter presents the following content: Graphic window, edit window, start button, matrices in matlab, scalar operations, order of operations, array operations, matrix addition, matrix multiplication, number display (scientific notation), script m-files.
Nội dung trích xuất từ tài liệu:
Lecture note Data visualization - Chapter 20Lecture20RecapGraphicWindowEditWindowStartButtonMatricesinMATLABScalarOperationsOrderofOperationsArrayOperationsMatrixAdditionTypesofMfilesTwotypes Script FunctionScriptMfileThescriptcanuseanyvariablesthathavebeendefinedin theworkspace,andanyvariablescreatedinthescriptare addedtotheworkspacewhenthescriptexecutesAscriptcreatedintheMATLABeditwindowcanbe executedbyselectingtheSaveandRuniconfromthe menubarAscriptcanbeexecutedbytypingafilenameorbyusing theruncommandfromthecommandwindowNomatterhowyoudoit,youcanonlyrunanMfileifit isinthecurrentfolderEditor/DebuggerWindowCellModeItisautilitythatallowstheusertodivideMfilesinto sections,orcells,thatcanbeexecutedoneatatimeThisfeatureisparticularlyusefulasdevelopMATLAB® programsaredevelopedToactivatethecellmode,select Cell>EnableCellMode fromthemenubarintheeditwindowOncethecellmodehasbeenenabled,thecelltoolbar appearsIt’simportanttoincludethespaceafterthedoubleContinued…. percentagesign(%%).Ifdon’t,thelineisrecognizedasa comment,notacelldividerOncethecelldividersareinplace,ifcursorispositioned anywhereinsidethecell,theentirecellturnspaleyellowNowusetheevaluationiconsonthecelltoolbarto evaluateasinglesection,evaluatethecurrentsectionand moveontothenextsection,orevaluatetheentirefileAlsoonthecelltoolbarisaniconthatlistsallthecell titlesintheMfileContinued….Bydividingtheprogramintocells,itwaspossibleto workoneachproblemseparatelyBesuretosaveanyMfilesdevelopedthiswayby selectingSaveorSaveAsfromthefilemenu: File>Save or File>SaveAsThereasonforusingthesecommandsisthatincellmode, theprogramisnotautomaticallysavedeverytimewhenit isrunSummaryofChapter Chapter3BuiltinMATLABFunctionUsingBuiltinFunctionsManyofthenamesforMATLAB’sbuiltinfunctionsare thesameasthosedefinednotonlyintheCprogramming language,butinFortranandJavaaswellForexample:totakethesquarerootofthevariablex, wetypeb=sqrt(x)AbigadvantageofMATLABisthatfunctionarguments cangenerallybeeitherscalarsormatricesInourexample,ifxisascalar,ascalarresultisreturnedThus,thestatementContinued….However,thesquarerootfunction,sqrt,canalsoaccept matricesasinputInthiscase,thesquarerootofeachelementiscalculated, so x=[4,9,16]; b=sqrt(x) returns b=234AllfunctionscanbethoughtofashavingthreeContinued….SomefunctionsrequiremultipleinputsForexample:theremainderfunction,rem,requirestwo inputs:adividendandadivisor.Werepresentthisas rem(x,y),sorem(10,3)calculatestheremainderof10dividedby3:ans=1Thesizefunctionisanexampleofafunctionthatreturns twooutputs,whicharestoredinasinglearray.It determinesthenumberofrowsandcolumnsinamatrix.Continued….AusefulfeatureofthemorerecentversionsofMATLAB istheadaptivehelpcapabilityAsafunctionnameistyped,ascreentipappears showingthecorrectfunctionformatItalsoincludesalinktothefunction’shelppage.Amorecomplicatedexpressionscanbecreatedby nestingfunctionsForinstance: g=sqrt(sin(x))UsingtheHELPFeatureMATLABincludesextensivehelptools,whichare especiallyusefulinunderstandinghowtousefunctionsTherearetwowaystogethelpfromwithinMATLAB Acommandlinehelpfunction AnHTMLbasedsetofdocumentationavailableby selectingHelpfromthemenubar,selectingthehelpiconor byusingtheF1functionkeyThereisalsoanonlinehelpsetofdocumentation, availablethroughtheStartbuttonortheHelpicononthe menubarContinued….Tousethecommandlinehelpfunction,typehelpinthe commandwindow helpAlistofhelptopicswillappear: HELPtopics: MATLAB\general –Generalpurposecommands MATLAB\ops –Operatorsandspecialcharacters MATLAB\lang –Programminglanguageconstructs MATLAB\elmat –ElementarymatricesandmatrixExampletogethelponthetangentfunction,type helptanThefollowingshouldbedisplayed: TAN Tangentofargumentinradians. TAN(X)isthetangentoftheelementsofX Seealsoatan,tand,atan2

Tài liệu được xem nhiều: