Danh mục

Lecture note Data visualization - Chapter 30

Số trang: 32      Loại file: pptx      Dung lượng: 2.02 MB      Lượt xem: 2      Lượt tải: 0    
10.10.2023

Phí tải xuống: 16,000 VND Tải xuống file đầy đủ (32 trang) 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: Cubic spline interpolation, multidimensional interpolation, curve fitting, linear regression, polynomial regression, the polyval function, the interactive fitting tools, basic curve fitting, curve fitting toolbox, numerical integration.
Nội dung trích xuất từ tài liệu:
Lecture note Data visualization - Chapter 30Lecture30RecapCubicSplineInterpolationMultidimensionalInterpolationCurveFitting LinearRegression PolynomialRegression ThePolyvalFunction TheInteractiveFittingTools BasicCurveFittingCurveFittingToolBox NumericalIntegration ExampleHere’sanotherexample,usinga functionhandleandananonymous function,insteadofdefiningthe functioninsidesinglequoteFirstdefineananonymous functionforathirdorder polynomial fun_handle=@(x)x.^3+20*x.^2 5Nowplotthefunction,toseehow itbehaves.TheeasiestapproachisExampleContinued….SolvingDifferentialEquationNumericallyContinued….Eachsolverrequiresthefollowingthreeinputsasa minimum: Afunctionhandletoafunctionthatdescribesthefirst orderdifferentialequationorsystemofdifferential equationsintermsoftandy Thetimespanofinterest AninitialconditionforeachequationinthesystemThesolversallreturnanarrayoftandyvalues: [t,y]=odesolver(function_handle,[initial_time,final_time], [initial_cond_array])FunctionHandleInputContinued….SolvingtheProblemContinued….Continued….Whentheinputfunctionorsystemoffunctionsisstored inanMfile,thesyntaxisslightlydifferentThehandleforanexistingMfileisdefinedas @m_file_nameTosolvethesystemofequationsdescribedintwofunwe usethecommand ode45(@twofun,[1,1],[1,1])Thetimespanofinterestisfrom1to1,andtheinitial conditionsareboth1SolvingHigherOrderDifferentialEquationsContinued….NowallweneedtodoiscreateanMfilefunctiontouse inoneoftheodesolversThefunctionshouldhavetwoinputs,whicharetypically calledtandyThevariabletistheindependentvariable,andthe variableyisanarrayofdependentvariablesInthisexampley(1)correspondstotheyusedinthe handformulation,andy(2)correspondstozThefunctioncontainingthesystemofequationsshould looklikethis: functiondydt=twoeq(t,y)Continued….OncethesystemofequationsisdefinedinafunctionM fileitisavailabletouseasinputtoanodesolverForexample:iftherangeoftimeisdefinedas1to+1 andtheinitialconditionsaredefinedasy=0andz=0, thenthecommandbecomes ode45(@twoeq,[1,1],[0,0])whichgivestheresultsAproblemwherethestartingvaluesareknowniscalled aninitialvalueproblemBoundaryValueProblemsbvp4cfunctionisusedtosolveboundaryvalueproblemsThebvp4cfunctionrequiresthreeinputs: Afunctionhandletothesystemofode’stobesolved Afunctionhandletoafunctionthatsolvesfortheresidual valuesofthefunction AsetofguessesfortheinitialconditionsContinued….Thefirstfunctionhandleisexactlythesameasweused fortheodesolversetoffunctionsItshouldcontaintheequationsforthederivativesof interestandtheresultsmustbeacolumnvectorTosolvetheproblemaguessismadefortheinitialvalue ofallthederivatives,thentheprogramcheckstoseehow itdidbycomparingthecalculatedboundaryvalueswith theactualvaluesForexample,if: att=1,y=0and att=1,y=3

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