Danh mục

Lecture note Data visualization - Chapter 19

Số trang: 28      Loại file: pptx      Dung lượng: 900.38 KB      Lượt xem: 2      Lượt tải: 0    
thaipvcb

Phí tải xuống: 7,000 VND Tải xuống file đầy đủ (28 trang) 0
Xem trước 3 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

In this lecture we learned about: Checking an algorithm analysis, limitations of big-oh analysis, matlab environment, command window, command history, workspace window, current folder window, document window.
Nội dung trích xuất từ tài liệu:
Lecture note Data visualization - Chapter 19Lecture19RecapCheckinganAlgorithmAnalysisLimitationsofBigOhAnalysisMATLABEnvironmentCommandWindowCommandHistoryWorkspaceWindowCurrentFolderWindowDocumentWindowGraphicsWindowThegraphicswindowlaunchesautomaticallywhen requesttoagraphismadeTodemonstratethisfeature,firstcreateanarrayofx values: x=[12345];Nowcreatealistofyvalues: y=[1020304050];Tocreateagraph,usetheplotcommand: plot(x,y)GraphicWindowEditWindowToopentheeditwindow,chooseFilefromthemenubar, thenNew,and,finally Script(File>New>Script)Thiswindowallowstotypeandsaveaseriesof commandswithoutexecutingthemEditwindowcanalsobeopenedbytypingeditatthe commandpromptorbyselectingtheNewScriptbutton onthetoolbarStartButtonThestartbuttonislocatedinthelowerlefthandcornerof theMATLABwindowItoffersalternativeaccesstothevariousMATLAB windows,aswellastothehelpfunction,Internet products,demosandMATLABtoolboxesToolboxesprovideadditionalMATLABfunctionalityfor specificcontentareasThesymbolictoolboxinparticularishighlyusefulto scientistsandengineersMatricesinMATLABThebasicdatatypeusedinMATLABisthematrixAsinglevalue,calledascalar,isrepresentedasa1X1 matrixAlistofvalues,arrangedineitheracolumnorarow,isa onedimensionalmatrixcalledavector.Atableofvaluesisrepresentedasatwodimensional matrixMATLABcanhandlehigherorderarrays.Thetermsmatrixandarrayareusedinterchangeablyby MATLABusers,eventhoughtheyaretechnicallyContinued….ScalarOperationsMATLAB®handlesarithmeticoperationsbetweentwo scalarsmuchasdoothercomputerprogramsandeven calculatorContinued….Thecommand a=1+2shouldbereadas“aisassignedavalueof1plus2,”whichistheadditionoftwoscalarquantities.Asingleequalssign(=)iscalledanassignmentoperator inMATLABTheassignmentoperatorcausestheresultofcalculations tobestoredinacomputermemorylocationTheassignmentoperatorissignificantlydifferentfroman equality.ConsiderthestatementContinued….Theassignmentstatementissimilartothefamiliar processofsavingafileWhenawordprocessingdocumentissavedatfirst,a nameisassignedtoitSubsequently,afterchangeshavebeenmade,fileis resaved,butstillassigningitthesamenameThefirstandsecondversionsarenotequal:justanew versionofdocumenthavebeenassignedtoanexisting memorylocationOrderofOperationsInallmathematicalcalculations,itisimportantto understandtheorderinwhichoperationsareperformedMATLABfollowsthestandardalgebraicrulesforthe orderofoperation: Firstperformcalculationsinsideparentheses,workingfrom theinnermostsettotheoutermost Next,performexponentiationoperations Thenperformmultiplicationanddivisionoperations, workingfromlefttoright Finally,performadditionandsubtractionoperations,ExampleConsiderthecalculationsinvolvedinfindingthesurface areaofarightcircularcylinderThesurfaceareaisthesumoftheareasofthetwocircular basesandtheareaofthecurvedsurfacebetweenthemIfwelettheheightofthecylinderbe10cmandtheradius 5cm,thefollowingMATLABcodecanbeusedtofind thesurfacearea: radius=5; height=10; surface_area=2*pi*radius^2+2*pi*radius*height OrderofOperationsContinued…ArrayOperationsUsingMATLABasaglorifiedcalculatorisfine,butits realstrengthisinmatrixmanipulationsThesimplestwaytodefineamatrixistousealistof numbers,calledanexplicitlistThecommand x=[1234]returnstherowvector x=1234Anewrowisindicatedbyasemicolon,soacolumnContinued….Acomplicatedmatrixmighthavetobeenteredbyhand, evenlyspacedmatricescanbeenteredmuchmorereadilyThecommand b=1:5andthecommand b=[1:5]areequivalentstatementsBothreturnarowmatrixb=12345Continued….Tocalculatethespacingbetweenelements,thelinspace commandisusedSpecifytheinitialvalue,thefinalvalue,andhowmany totalvaluesyouwantForexample, d=linspace(1,10,3)returnsavectorwiththreevalues,evenlyspacedbetween1and10: d=15.510Continued….Logarithmicallyspacedvectorscanbecreatedwiththe logspacecommand,whichalsorequiresthreeinputsThefirsttwovaluesarepowersof10representingthe initialandfinalvaluesinthearrayThefinalvalueisthenumberofelementsinthearrayThus, e=logspace(1,3,3)returnsthreevalues: e=101001000MatrixAdditionwithScalarMatricescanbeusedinmanycalculationswithscalarsIfa=[123],wecanadd5toeachvalueinthematrix withthesyntax b=a+5whichreturns b=678ThisapproachworkswellforadditionandsubtractionMultiplicationinMatrixInmatrixmathematics,themultiplicationoperator(*)has aspecificmeaningBecauseallMATLABoperationscaninvolvematrices, weneedadifferentoperatortoindicateelementby elementmultiplication.Thatoperatoris.*Forexample:a.*bresultsin element1ofmatrixabeingmultipliedbyelement1of matrixb ...

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