Danh mục

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    
10.10.2023

Hỗ trợ phí lưu trữ khi tải xuống: 13,000 VND Tải xuống file đầy đủ (16 trang) 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 28Lecture28RecapFunctionswithNoinputORNooutputDeterminingTheNumberofInputandOutputArgumentsLocalVariablesGlobalVariablesCreatingToolBoxofFunctionsAnonymousFunctionsandFunctionHandlesFunctionFunctionsSubfunctionsSummaryofChapterMATLABcontainsawidevarietyofbuiltinfunctionsHowever,youwilloftenfinditusefultocreateyourown MATLABfunctionsThemostcommontypeofuserdefinedMATLAB functionisthefunctionMfile,whichmuststartwitha functiondefinitionlinethatcontains thewordfunction avariablethatdefinesthefunctionoutput afunctionname avariableusedfortheinputargumentContinued….ThefunctionnamemustalsobethenameoftheMfilein whichthefunctionisstoredFunctionnamesfollowthestandardMATLABnaming rulesLikethebuiltinfunctions,userdefinedfunctionscan acceptmultipleinputsandcanreturnmultipleresultsCommentsimmediatelyfollowingthefunctiondefinition linecanbeaccessedfromthecommandwindowwiththe helpcommandVariablesdefinedwithinafunctionarelocaltothat function.TheyarenotstoredintheworkspaceandcannotContinued….Groupsofuserdefinedfunctions,called“toolboxes,”may bestoredinacommondirectoryandaccessedby modifyingtheMATLAB®searchpath.Thisis accomplishedinteractivelywiththepathtool,eitherfrom themenubar,asin File>SetPathorfromthecommandline,withpathtoolMATLABprovidesaccesstonumeroustoolboxes developedatTheMathWorksorbytheusercommunityAnothertypeoffunctionistheanonymousfunction, Chapter13NumericalTechniquesIntroductionInterpolatebetweendatapoints,usingeitherlinearor cubicsplinemodelsModelasetofdatapointsasapolynomialUsethebasicfittingtoolUsethecurvefittingtoolboxPerformnumericaldifferentiationsPerformnumericalintegrationsSolvedifferentialequationsnumericallyInterpolationEspeciallywhenwemeasurethings,wedon’tgatherdata ateverypossibledatapointConsiderasetofx–ydatacollectedduringanexperimentByusinganinterpolationtechnique,wecanestimatethe valueofyatvaluesofxwherewedidn’ttake measurementThetwomostcommoninterpolationtechniquesare Linearinterpolation CubicsplineinterpolationInterpolationbetweendatapointsLinearInterpolationThemostcommonwaytoestimateadatapointbetween twoknownpointsislinearinterpolationInthistechnique,weassumethatthefunctionbetweenthe pointscanbeestimatedbyastraightlinedrawnbetween themIfwefindtheequationofastraightlinedefinedbythe twoknownpoints,wecanfindyforanyvalueofxTheclosertogetherthepointsare,themoreaccurateour approximationislikelytobeContinued….WecanperformlinearinterpolationinMATLABwiththe interp1functionWe’llfirstneedtocreateasetoforderedpairstouseas inputtothefunctionThedatausedtocreatetherighthandgraphofnextfigure is x=0:5; y=[15,10,9,6,2,0];Continued….Toperformasingleinterpolation,theinputtointerp1is thexdata,theydata,andthenewxvalueforwhichyou’d likeanestimateofyForexample:toestimatethevalueofywhenxisequal to3.5,type interp1(x,y,3.5) ans=4Youcanperformmultipleinterpolationsallatthesame timebyputtingavectorofxvaluesinthethirdfieldof theinterp1functionForexample:toestimateyvaluesfornewx’sspaced evenlyfrom0to5by0.2,typeContinued….Theinterp1functiondefaultstolinearinterpolationto makeitsestimates.However,otherapproachesare possibleIfwewant(probablyfordocumentationpurposes)to explicitlydefinetheapproachusedininterp1aslinear interpolation,wecanspecifyitinafourthfield: interp1(x,y,3.5,linear) ans=4

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