微分方程(ODEs)解算器(中文版).docx_第1页
微分方程(ODEs)解算器(中文版).docx_第2页
微分方程(ODEs)解算器(中文版).docx_第3页
微分方程(ODEs)解算器(中文版).docx_第4页
微分方程(ODEs)解算器(中文版).docx_第5页
已阅读5页,还剩2页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

微分方程(ODEs)解算器1.先来认识下常微分方程(ODE)初值问题解算器(solver)T,Y,TE,YE,IE = odesolver(odefun,tspan,y0,options)sxint = deval(sol,xint)Matlab中提供了以下解算器:输入参数:odefun:微分方程的Matlab语言描述函数,必须是函数句柄或者字符串,必须写成Matlab规范格式(也就是一阶显式微分方程组)tspan=t0 tf或者t0,t1,tf:微分变量的范围,两者都是根据t0和tf的值自动选择步长,只是前者返回所有计算点的微分值,而后者只返回指定的点的微分值,一定要注意对于后者tspan必须严格单调,还有就是两者数据存储时使用的内存不同(明显前者多),其它没有任何本质的区别y0=y(0),y(0),y(0):微分方程初值,依次输入所有状态变量的初值options:微分优化参数,是一个结构体,使用odeset可以设置具体参数,详细内容查看帮助(如下是Matlab 中odeset的说明: help odeset ODESET Create/alter ODE OPTIONS structure. OPTIONS = ODESET(NAME1,VALUE1,NAME2,VALUE2,.) creates an integrator options structure OPTIONS in which the named properties have the specified values. Any unspecified properties have default values. It is sufficient to type only the leading characters that uniquely identify the property. Case is ignored for property names. OPTIONS = ODESET(OLDOPTS,NAME1,VALUE1,.) alters an existing options structure OLDOPTS. OPTIONS = ODESET(OLDOPTS,NEWOPTS) combines an existing options structure OLDOPTS with a new options structure NEWOPTS. Any new properties overwrite corresponding old properties. ODESET with no input arguments displays all property names and their possible values. ODESET PROPERTIES RelTol - Relative error tolerance positive scalar 1e-3 This scalar applies to all components of the solution vector, and defaults to 1e-3 (0.1% accuracy) in all solvers. The estimated error in each integration step satisfies e(i) = max(RelTol*abs(y(i),AbsTol(i). AbsTol - Absolute error tolerance positive scalar or vector 1e-6 A scalar tolerance applies to all components of the solution vector. Elements of a vector of tolerances apply to corresponding components of the solution vector. AbsTol defaults to 1e-6 in all solvers. See RelTol. NormControl - Control error relative to norm of solution on | off Set this property on to request that the solvers control the error in each integration step with norm(e) 2 or the ODE solver returns the solution as a structure. OutputFcn - Installable output function function This output function is called by the solver after each time step. When a solver is called with no output arguments, OutputFcn defaults to the function odeplot. Otherwise, OutputFcn defaults to . OutputSel - Output selection indices vector of integers This vector of indices specifies which components of the solution vector are passed to the OutputFcn. OutputSel defaults to all components. Stats - Display computational cost statistics on | off Jacobian - Jacobian function function | constant matrix Set this property to a function FJac (if FJac(t,y) returns dF/dy) or to the constant value of dF/dy. For ODE15I solving F(t,y,y) = 0, set this property to a function dFdy, dFdyp = FJac(t,y,yp), or to a cell array of constant values dF/dy,dF/dyp. JPattern - Jacobian sparsity pattern sparse matrix Set this property to a sparse matrix S with S(i,j) = 1 if component i of F(t,y) depends on component j of y, and 0 otherwise. For ODE15I solving F(t,y,y) = 0, set this property to dFdyPattern,dFdypPattern, the sparsity patterns of dF/dy and dF/dy, respectively. Vectorized - Vectorized ODE function on | off Set this property on if the ODE function F is coded so that F(t,y1 y2 .) returns F(t,y1) F(t,y2) . For ODE15I solving F(t,y,y) = 0, set this property to yVect,ypVect. Setting yVect on indicates that F(t,y1 y2 .,yp) returns F(t,y1,yp) F(t,y2,yp) . Setting ypVect on indicates that F(t,y,yp1 yp2 .) returns F(t,y,yp1) F(t,y,yp2) . Events - Locate events function To detect events, set this property to the event function. Mass - Mass matrix constant matrix | function For problems M*y = f(t,y) set this property to the value of the constant mass matrix. For problems with time- or state-dependent mass matrices, set this property to a function that evaluates the mass matrix. MStateDependence - Dependence of the mass matrix on y none | weak | strong Set this property to none for problems M(t)*y = F(t,y). Both weak and strong indicate M(t,y), but weak will result in implicit solvers using approximations when solving algebraic equations. MassSingular - Mass matrix is singular yes | no | maybe Set this property to no if the mass matrix is not singular. MvPattern - dMv/dy sparsity pattern sparse matrix Set this property to a sparse matrix S with S(i,j) = 1 if for any k, the (i,k) component of M(t,y) depends on component j of y, and 0 otherwise. InitialSlope - Consistent initial slope yp0 vector yp0 satisfies M(t0,y0)*yp0 = F(t0,y0). InitialStep - Suggested initial step size positive scalar The solver will try this first. By default the solvers determine an initial step size automatically. MaxStep - Upper bound on step size positive scalar MaxStep defaults to one-tenth of the tspan interval in all solvers. BDF - Use Backward Differentiation Formulas in ODE15S on | off This property specifies whether the Backward Differentiation Formulas (Gears methods) are to be used in ODE15S instead of the default Numerical Differentiation Formulas. MaxOrder - Maximum order of ODE15S 1 | 2 | 3 | 4 | 5 See also odeget, ode45, ode23, ode113, ode15i, ode15s, ode23s, ode23t, ode23tb. NOTE: Some of the properties available through ODESET have changed in this version of MATLAB. Although we still support the v5 properties when used with the v5 syntax of the ODE solvers, any new functionality will be available only with the new syntax. To see the properties available in v5, type in the command line more on, type odeset, more off Reference page in Help browser doc odeset)输出参数:T:时间列向量,也就是ode*计算微分方程的值的点Y:二维数组,第i列表示第i个状态变量的值, 行数与T一致在求解ODE时,我们还会用到deval()函数,deval的作用就是通过结构体solution计算t对应x值,和polyval之类的很相似!参数格式如下:sol:就是上次调用ode*函数得到的结构体解xint:需要计算的点,可以是标量或者向量,但是必须在tspan范围内2.微分方程转换为一阶显式微分方程组方法现实总是残酷的,要得到就必须先付出,不可能所有的ODE一拿来就可以直接使用,因此在使用ODE解算器之前,我们需要做的第一步,也是最重要的一步,借助状态变量将微分方程组化成Matlab可接受的标准形式(一阶显示常微分方程)!下面我们以两个高阶微分方程构成的ODEs为例介绍如何将之变换成一个一阶显式常微分方程组。step1.将微分方程的最高阶变量移到等式的左边,其他移到右边,并按阶次从低到高排列,假如说两个高阶微分方程最后能够显式的表达成如下所示:step2.为每一阶微分式选择状态变量,最高阶除外step3.根据上面选用

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论