Lecture note Data visualization - Chapter 28
Số trang: 16
Loại file: pptx
Dung lượng: 479.18 KB
Lượt xem: 14
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
The main contents of the chapter consist of the following: Functions with no input or no output, determining the number of input and output arguments, local variables, global variables, creating toolbox of functions, anonymous functions and function handles, function functions, subfunctions.
Nội dung trích xuất từ tài liệu:
Lecture note Data visualization - Chapter 28Lecture28RecapFunctionswithNoinputORNooutputDeterminingTheNumberofInputandOutputArgumentsLocalVariablesGlobalVariablesCreatingToolBoxofFunctionsAnonymousFunctionsandFunctionHandlesFunctionFunctionsSubfunctionsSummaryofChapterMATLABcontainsawidevarietyofbuiltinfunctionsHowever,youwilloftenfinditusefultocreateyourown MATLABfunctionsThemostcommontypeofuserdefinedMATLAB functionisthefunctionMfile,whichmuststartwitha functiondefinitionlinethatcontains thewordfunction avariablethatdefinesthefunctionoutput afunctionname avariableusedfortheinputargumentContinued….ThefunctionnamemustalsobethenameoftheMfilein whichthefunctionisstoredFunctionnamesfollowthestandardMATLABnaming rulesLikethebuiltinfunctions,userdefinedfunctionscan acceptmultipleinputsandcanreturnmultipleresultsCommentsimmediatelyfollowingthefunctiondefinition linecanbeaccessedfromthecommandwindowwiththe helpcommandVariablesdefinedwithinafunctionarelocaltothat function.TheyarenotstoredintheworkspaceandcannotContinued….Groupsofuserdefinedfunctions,called“toolboxes,”may bestoredinacommondirectoryandaccessedby modifyingtheMATLAB®searchpath.Thisis accomplishedinteractivelywiththepathtool,eitherfrom themenubar,asin File>SetPathorfromthecommandline,withpathtoolMATLABprovidesaccesstonumeroustoolboxes developedatTheMathWorksorbytheusercommunityAnothertypeoffunctionistheanonymousfunction, Chapter13NumericalTechniquesIntroductionInterpolatebetweendatapoints,usingeitherlinearor cubicsplinemodelsModelasetofdatapointsasapolynomialUsethebasicfittingtoolUsethecurvefittingtoolboxPerformnumericaldifferentiationsPerformnumericalintegrationsSolvedifferentialequationsnumericallyInterpolationEspeciallywhenwemeasurethings,wedon’tgatherdata ateverypossibledatapointConsiderasetofx–ydatacollectedduringanexperimentByusinganinterpolationtechnique,wecanestimatethe valueofyatvaluesofxwherewedidn’ttake measurementThetwomostcommoninterpolationtechniquesare Linearinterpolation CubicsplineinterpolationInterpolationbetweendatapointsLinearInterpolationThemostcommonwaytoestimateadatapointbetween twoknownpointsislinearinterpolationInthistechnique,weassumethatthefunctionbetweenthe pointscanbeestimatedbyastraightlinedrawnbetween themIfwefindtheequationofastraightlinedefinedbythe twoknownpoints,wecanfindyforanyvalueofxTheclosertogetherthepointsare,themoreaccurateour approximationislikelytobeContinued….WecanperformlinearinterpolationinMATLABwiththe interp1functionWe’llfirstneedtocreateasetoforderedpairstouseas inputtothefunctionThedatausedtocreatetherighthandgraphofnextfigure is x=0:5; y=[15,10,9,6,2,0];Continued….Toperformasingleinterpolation,theinputtointerp1is thexdata,theydata,andthenewxvalueforwhichyou’d likeanestimateofyForexample:toestimatethevalueofywhenxisequal to3.5,type interp1(x,y,3.5) ans=4Youcanperformmultipleinterpolationsallatthesame timebyputtingavectorofxvaluesinthethirdfieldof theinterp1functionForexample:toestimateyvaluesfornewx’sspaced evenlyfrom0to5by0.2,typeContinued….Theinterp1functiondefaultstolinearinterpolationto makeitsestimates.However,otherapproachesare possibleIfwewant(probablyfordocumentationpurposes)to explicitlydefinetheapproachusedininterp1aslinear interpolation,wecanspecifyitinafourthfield: interp1(x,y,3.5,linear) ans=4
Nội dung trích xuất từ tài liệu:
Lecture note Data visualization - Chapter 28Lecture28RecapFunctionswithNoinputORNooutputDeterminingTheNumberofInputandOutputArgumentsLocalVariablesGlobalVariablesCreatingToolBoxofFunctionsAnonymousFunctionsandFunctionHandlesFunctionFunctionsSubfunctionsSummaryofChapterMATLABcontainsawidevarietyofbuiltinfunctionsHowever,youwilloftenfinditusefultocreateyourown MATLABfunctionsThemostcommontypeofuserdefinedMATLAB functionisthefunctionMfile,whichmuststartwitha functiondefinitionlinethatcontains thewordfunction avariablethatdefinesthefunctionoutput afunctionname avariableusedfortheinputargumentContinued….ThefunctionnamemustalsobethenameoftheMfilein whichthefunctionisstoredFunctionnamesfollowthestandardMATLABnaming rulesLikethebuiltinfunctions,userdefinedfunctionscan acceptmultipleinputsandcanreturnmultipleresultsCommentsimmediatelyfollowingthefunctiondefinition linecanbeaccessedfromthecommandwindowwiththe helpcommandVariablesdefinedwithinafunctionarelocaltothat function.TheyarenotstoredintheworkspaceandcannotContinued….Groupsofuserdefinedfunctions,called“toolboxes,”may bestoredinacommondirectoryandaccessedby modifyingtheMATLAB®searchpath.Thisis accomplishedinteractivelywiththepathtool,eitherfrom themenubar,asin File>SetPathorfromthecommandline,withpathtoolMATLABprovidesaccesstonumeroustoolboxes developedatTheMathWorksorbytheusercommunityAnothertypeoffunctionistheanonymousfunction, Chapter13NumericalTechniquesIntroductionInterpolatebetweendatapoints,usingeitherlinearor cubicsplinemodelsModelasetofdatapointsasapolynomialUsethebasicfittingtoolUsethecurvefittingtoolboxPerformnumericaldifferentiationsPerformnumericalintegrationsSolvedifferentialequationsnumericallyInterpolationEspeciallywhenwemeasurethings,wedon’tgatherdata ateverypossibledatapointConsiderasetofx–ydatacollectedduringanexperimentByusinganinterpolationtechnique,wecanestimatethe valueofyatvaluesofxwherewedidn’ttake measurementThetwomostcommoninterpolationtechniquesare Linearinterpolation CubicsplineinterpolationInterpolationbetweendatapointsLinearInterpolationThemostcommonwaytoestimateadatapointbetween twoknownpointsislinearinterpolationInthistechnique,weassumethatthefunctionbetweenthe pointscanbeestimatedbyastraightlinedrawnbetween themIfwefindtheequationofastraightlinedefinedbythe twoknownpoints,wecanfindyforanyvalueofxTheclosertogetherthepointsare,themoreaccurateour approximationislikelytobeContinued….WecanperformlinearinterpolationinMATLABwiththe interp1functionWe’llfirstneedtocreateasetoforderedpairstouseas inputtothefunctionThedatausedtocreatetherighthandgraphofnextfigure is x=0:5; y=[15,10,9,6,2,0];Continued….Toperformasingleinterpolation,theinputtointerp1is thexdata,theydata,andthenewxvalueforwhichyou’d likeanestimateofyForexample:toestimatethevalueofywhenxisequal to3.5,type interp1(x,y,3.5) ans=4Youcanperformmultipleinterpolationsallatthesame timebyputtingavectorofxvaluesinthethirdfieldof theinterp1functionForexample:toestimateyvaluesfornewx’sspaced evenlyfrom0to5by0.2,typeContinued….Theinterp1functiondefaultstolinearinterpolationto makeitsestimates.However,otherapproachesare possibleIfwewant(probablyfordocumentationpurposes)to explicitlydefinetheapproachusedininterp1aslinear interpolation,wecanspecifyitinafourthfield: interp1(x,y,3.5,linear) ans=4
Tìm kiếm theo từ khóa liên quan:
Data visualization Lecture note Data visualization Data structures Data Visualization with C Data visualization with matlab Effective graphical displayTài liệu liên quan:
-
Trực quan hóa dữ liệu: Vai trò & thử thách
10 trang 37 0 0 -
Ebook Eloquent JavaScript - A modern introduction to programming: Part 1
199 trang 33 0 0 -
Ebook Management support systems: Part 2 - Dr. Kamlesh Lakhwani
136 trang 31 0 0 -
Lecture Introduction to computing systems (2/e): Chapter 19 - Yale N. Patt, Sanjay J. Patel
28 trang 30 0 0 -
Ebook Introduction to algorithms (3rd edition)
1313 trang 28 0 0 -
Lecture Data Structures: Lesson 38
71 trang 27 0 0 -
Lecture Data structures and algorithms: Chapter 1 - Introduction
41 trang 26 0 0 -
Lecture note Data visualization - Chapter 22
21 trang 24 0 0 -
169 trang 24 0 0
-
Lecture Data Structures: Lesson 41
18 trang 23 0 0