matlab中mathematics+工具箱使用.doc
《matlab中mathematics+工具箱使用.doc》由会员分享,可在线阅读,更多相关《matlab中mathematics+工具箱使用.doc(19页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、【精品文档】如有侵权,请联系网站删除,仅供学习与交流matlab中mathematics+工具箱使用.精品文档.Matlab中Mathematics 工具箱使用第8章 最优化方法8.1最优化非线性函数工具箱提供的Humps函数,其图像如下: 函数fminbnd可求单变量函数在给定区间的局部最小点,如x=fminbnd(humps,0.3,1) x=0.6370通过设置第4个参数optimset可实现显示迭代列表,如x = fminbnd(humps,0.3,1,optimset(Display,iter) fminsearch 函数求多变量函数的局部极小点。首先,创建三变量函数three_va
2、r b=(x) x(1)2+2.5*sin(x(2)-x(3)2*x(1)2*x(2)2a=fminsearch(b,-0.6,-1.2,0.135) 0.0000 -1.5708 0.1803第10章 微积分ODE求解器Solver(求解器)Solves These Kinds of Problems (求解问题)Method(方法)ode45Nonstiff differential equations(非刚性微分方程)Runge-Kuttaode23Nonstiff differential equations(非刚性微分方程)Runge-Kuttaode113Nonstiff diff
3、erential equations (非刚性微分方程)Adamsode15sStiff differential equations and DAEs(非刚性微分-代数方程)NDFs (BDFs)ode23sStiff differential equations (刚性微分方程) Rosenbrockode23tModerately stiff differential equations and DAEs(中等刚性微分方程和代数方程)Trapezoidal ruleode23tbStiff differential equations(刚性微分方程)TR-BDF2ode15iFully
4、implicit differential equations(全隐式微分方程)BDFsEvaluation and Extension(赋值和延拓)You can use the following functions to evaluate and extend solutions to ODEs.你能应用如下函数对ODE的数值解解进行赋值和延拓。FunctionDescriptiondeval Evaluate the numerical solution using the output of ODE solvers(用ODE输出对数值解进行赋值)odextendExtend the
5、solution of an initial value problem for an ODE对ODE初值问题的解进行延拓Solver Options(求解器选项)An options structure contains named properties whose values are passed to ODE solvers, and which affect problem solution. Use these functions to create, alter, or access an options structure. 选项结构包含署名属性,其值传递给ODE求解器以影响问
6、题求解。用这些函数可以创建,改变和接受选项结构。Function(函数) Description(描述)odeset Create or alter options structure for input to ODE solver.(创建和改变选项)odeget Extract properties from options structure created with odeset. (提取属性选项)Output Functions(输出函数)If an output function is specified, the solver calls the specified functio
7、n after every successful integration step. You can use odeset to specify one of these sample functions as the OutputFcn property, or you can modify them to create your own functions.如果输出函数被指定,则求解器在每步积分后调用该函数进行输出。你能够用odeset 指定这些例子函数之一作为OutputFcn属性,或创建自己的函数对其进行修改。FunctionDescriptionodeplotTime-series
8、plot(时间序列图形)odephas2 Two-dimensional phase plane plot(2-维相平面图形)odephas3Three-dimensional phase plane plot(3-维相平面图形)odeprint Print to command window (打印到命令窗)First Order ODEs(一阶ODEs)An ordinary differential equation (ODE) contains one or more derivativesof a dependent variable y with respect to a sing
9、le independent variable t,usually referred to as time. The derivative of y with respect to t is denotedas y , the second derivative as y , and so on. Often y(t) is a vector, havingelements y1, y2, ., yn.MATLAB solvers handle the following types of first-order ODEs: Explicit ODEs of the form y = f (t
10、, y) 形如y = f (t, y)的显式ODEs Linearly implicit ODEs of the form M(t, y) y = f (t, y), where M(t, y) isa matrix形如M(t, y) y = f (t, y)的线性隐式ODEs Fully implicit ODEs of the form f (t, y, y) = 0 (ode15i only):形如f (t, y, y) = 0的全隐式ODEsHigher Order ODEs(高阶ODEs)MATLAB ODE solvers accept only first-order diffe
11、rential equations. To usethe solvers with higher-order ODEs, you must rewrite each equation as anequivalent system of first-order differential equations of the formy = f(t,y)You can write any ordinary differential equationy(n) = f(t,y,y,.,y(n 1)as a system of first-order equations by making the subs
12、titutionsy1 = y, y2 = y,., yn = y(n 1)y1= y, y2 = y, . , yn = y(n 1)The result is an equivalent system of n first-order ODEs.Rewrite the second-order van der Pol equationas a system of first-order ODEs.Initial Values(初值问题)Generally there are many functions y(t) that satisfy a given ODE, andadditiona
13、l information is necessary to specify the solution of interest. Inan initial value problem, the solution of interest satisfies a specific initialcondition, that is, y is equal to y0 at a given initial time t0. An initial valueproblem for an ODE is thenIf the function f (t, y) is sufficiently smooth,
14、 this problem has one and only onesolution. Generally there is no analytic expression for the solution, so it isnecessary to approximate y(t) by numerical means.Nonstiff Problems(刚性问题)There are three solvers designed for nonstiff problems:对于非刚性问题求解有3个求解器。ode45 Based on an explicit Runge-Kutta (4,5)
15、formula,the Dormand-Prince pair. It is a one-step solver in computing y(tn), it needs only the solution at the immediately preceding time point, y(tn1). In general,ode45 is the best function to apply as a “first try” for most problems. ode45 基于显式Runge-Kutta(4,5)公式,Dormand-Prince 对,它是计算y(tn)的单步求解器,只需
16、前一步的解y(tn-1).一般说来,ode45是对大多数问题的“第一试”的最好的函数。 ode23 Based on an explicit Runge-Kutta (2,3) pair of Bogacki and Shampine. It may be more efficient than ode45 at crude tolerances and in the presence of mild stiffness.Like ode45, ode23 is a one-step solver.ode113 Variable order Adams-Bashforth-Moulton PE
17、CE solver. It may be more efficient than ode45 at stringent tolerances and when the ODE function is particularly expensive to evaluate. ode113 is a multistep solverit normally needs the solutions at several preceding time points to compute the current solution.Stiff Problems(刚性问题)Not all difficult p
18、roblems are stiff, but all stiff problems are difficult forsolvers not specifically designed for them. Solvers for stiff problems can beused exactly like the other solvers. However, you can often significantlyimprove the efficiency of these solvers by providing them with additionalinformation about
19、the problem. (See “Integrator Options” on page 10-9.)There are four solvers designed for stiff problems: 并不是所有困难的问题都是刚性的,但是所有的刚性问题对于非专门为此设计的求解器来说都是困难的。Solver Syntax(求解语法)All of the ODE solver functions, except for ode15i, share a syntax that makesit easy to try any of the different numerical methods
20、, if it is not apparentwhich is the most appropriate. To apply a different method to the sameproblem, simply change the ODE solver function name. The simplest syntax,common to all the solver functions, is求解函数调用t,y = solver(odefun,tspan,y0,options)where solver is one of the ODE solver functions liste
21、d previously.其中,solver是如前列举的ODE求解函数The basic input arguments are举例:van der Pol Equation (Nonstiff)This example illustrates the steps for solving an initial value ODE problem:该例说明了求解ODE初值问题的步骤:1 Rewrite the problem as a system of first-order ODEs. Rewrite thevan der Pol equation (second-order)1.把高阶方程
22、表示为一阶方程组的等价形式。van der Pol 方程(二阶)where 0 is a scalar parameter, by making the substitution y1 = y2. Theresulting system of first-order ODEs is为标量常数。做代换,得到对应的一阶方程组2 Code the system of first-order ODEs. Once you represent the equationas a system of first-order ODEs, you can code it as a function that a
23、n ODEsolver can use. The function must be of the form2. 对一阶ODE方程组编写ODEfun函数,其形式为dydt = odefun(t,y)odefun函数程序function dydt = vdp1(t,y)dydt = y(2); (1-y(1)2)*y(2)-y(1);3. Apply a solver to the problem.(调用求解函数求解)Decide which solver you want to use to solve the problem. Then call thesolver and pass it t
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- matlab mathematics 工具箱 使用
限制150内