ImageVerifierCode 换一换
格式:DOCX , 页数:22 ,大小:116.43KB ,
资源ID:5800290      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/5800290.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(中mathematics工具箱使用.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

中mathematics工具箱使用.docx

1、中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_var b=(x) x(1)2+2.5*sin(x(2)-x(3)2*x(1)2*

2、x(2)2a=fminsearch(b,-0.6,-1.2,0.135) 0.0000 -1.5708 0.1803第10章 微积分ODE求解器Solver(求解器)Solves These Kinds ofProblems (求解问题)Method(方法)ode45Nonstiff differentialequations(非刚性微分方程)Runge-Kuttaode23Nonstiff differentialequations(非刚性微分方程)Runge-Kuttaode113Nonstiff differentialequations (非刚性微分方程)Adamsode15sStif

3、f differential equationsand DAEs(非刚性微分-代数方程)NDFs (BDFs)ode23sStiff differential equations (刚性微分方程) Rosenbrockode23tModerately stiffdifferential equationsand DAEs(中等刚性微分方程和代数方程)Trapezoidal ruleode23tbStiff differential equations(刚性微分方程)TR-BDF2ode15iFully implicit differentialequations(全隐式微分方程)BDFsEva

4、luation and Extension(赋值和延拓)You can use the following functions to evaluate and extend solutions to ODEs.你能应用如下函数对ODE的数值解解进行赋值和延拓。FunctionDescriptiondeval Evaluate the numerical solution using the outputof ODE solvers(用ODE输出对数值解进行赋值)odextendExtend the solution of an initial value problem foran ODE对O

5、DE初值问题的解进行延拓Solver Options(求解器选项)An options structure contains named properties whose values are passedto ODE solvers, and which affect problem solution. Use these functions tocreate, alter, or access an options structure. 选项结构包含署名属性,其值传递给ODE求解器以影响问题求解。用这些函数可以创建,改变和接受选项结构。Function(函数) Description(描述

6、)odesetCreate or alter options structure for input toODE solver.(创建和改变选项)odegetExtract properties from options structurecreated with odeset. (提取属性选项)Output Functions(输出函数)If an output function is specified, the solver calls the specified function afterevery successful integration step. You can use o

7、deset to specify one of thesesample functions as the OutputFcn property, or you can modify them tocreate your own functions.如果输出函数被指定,则求解器在每步积分后调用该函数进行输出。你能够用odeset 指定这些例子函数之一作为OutputFcn属性,或创建自己的函数对其进行修改。FunctionDescriptionodeplotTime-series plot(时间序列图形)odephas2Two-dimensional phase plane plot(2-维相平

8、面图形)odephas3Three-dimensional phase plane plot(3-维相平面图形)odeprintPrint 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 single independent variable t,usually referred to as time. The d

9、erivative 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, y)形如y = f (t, y)的显式ODEs Linearly implicit ODEs of the form

10、 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 differential equations. To usethe solvers with higher-order ODEs,

11、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 substitutionsy1 = y, y2 = y,., yn = y(n 1)y1= y, y2 = y, . , yn=

12、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, andadditional information is necessary to specify the solution of interes

13、t. 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, this problem has one and only onesolution. Generally there i

14、s 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) formula,the Dormand-Prince pair. It is a one-step solver in c

15、omputing y(tn), it needs only the solution at theimmediately preceding time point, y(tn1). In general,ode45 is the best function to apply as a “first try” formost problems.ode45 基于显式Runge-Kutta(4,5)公式,Dormand-Prince 对,它是计算y(tn)的单步求解器,只需前一步的解y(tn-1).一般说来,ode45是对大多数问题的“第一试”的最好的函数。 ode23 Based on an ex

16、plicit Runge-Kutta (2,3) pair of Bogackiand Shampine. It may be more efficient than ode45 atcrude tolerances and in the presence of mild stiffness.Like ode45, ode23 is a one-step solver.ode113 Variable order Adams-Bashforth-Moulton PECEsolver. It may be more efficient than ode45 at stringent toleran

17、ces and when the ODE function is particularlyexpensive to evaluate. ode113 is a multistep solveritnormally needs the solutions at several preceding timepoints to compute the current solution.Stiff Problems(刚性问题)Not all difficult problems are stiff, but all stiff problems are difficult forsolvers not

18、 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 the problem. (See “Integrator Options” on page 10-9.)There are four so

19、lvers 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, if it is not apparentwhich is the most appropriate. To apply a diffe

20、rent 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 listed previously.其中,solver是如前列举的ODE求解函数The basic input arguments are举例:van

21、 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.把高阶方程表示为一阶方程组的等价形式。van der Pol 方程(二阶)where 0 is a scalar parameter, by maki

22、ng 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 an ODEsolver can use. The function must be of the form2. 对一阶ODE方程组编写ODE

23、fun函数,其形式为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 the function you created to describe the first-order systemof ODEs, the

24、time interval on which you want to solve the problem, andan initial condition vector.决定用哪个求解函数求解问题,然后调用求解器,把创建的描述方程组的函数,求解区间,和初始条件传递给求解函数。For the van der Pol system, you can use ode45 on time interval 0 20 withinitial values y(1) = 2 and y(2) = 0.对于 Van der Pol 系统,你可以用ode45在时间区间0,20进行积分,初值条件为y(1)=2和

25、y(2)=0,其调用求解函数的方法为t,y = ode45(vdp1,0 20,2; 0);4 View the solver output. You can simply use the plot command to viewthe solver output.4.视图求解输出。你能够用plot命令视图解输出。plot(t,y(:,1),-,t,y(:,2),-)title(Solution of van der Pol Equation, mu = 1);xlabel(time t);ylabel(solution y);legend(y_1,y_2)As an alternative,

26、 you can use a solver output function to process the output.The solver calls the function specified in the integration property OutputFcnafter each successful time step. Use odeset to set OutputFcn to the desiredfunction. See Solver Output Properties, in the reference page for odeset, formore inform

27、ation about OutputFcn.作为选择,你能够用求解器输出处理输出。van der Pol Equation (Stiff)(刚性van der Pol 方程)This example presents a stiff problem. For a stiff problem, solutions canchange on a time scale that is very short compared to the interval ofintegration, but the solution of interest changes on a much longer time

28、 scale.Methods not designed for stiff problems are ineffective on intervals where thesolution changes slowly because they use time steps small enough to resolvethe fastest possible change.该例表示的是一个刚性问题。对于刚性问题,解在相对积分区间非常小的时间尺度上变化,感兴趣的解在更大的时间尺度上变化。不是专为刚性问题设计的方法在解变换缓慢的区间上是无效的,因为它用的时间步长非常小以适应分辨快速变化。When

29、is increased to 1000, the solution to the van der Pol equationchanges dramatically and exhibits oscillation on a much longer time scale.Approximating the solution of the initial value problem becomes a moredifficult task. Because this particular problem is stiff, a solver intended fornonstiff proble

30、ms, such as ode45, is too inefficient to be practical. A solversuch as ode15s is intended for such stiff problems.当增加到1000,vdp方程的解急剧变化,在更大时时间尺度上展示振荡。近似初值问题的解是一个困难的问题。因为这个特别的问题是刚性的,对于如ode45这样的非刚性求解器实际上是效率非常低的。象ode15s是适用于刚性问题的。The vdp1000 function evaluates the van der Pol system from the previousexam

31、ple, but with = 1000.vdp1000函数对的vdp方程组进行赋值。function dydt = vdp1000(t,y)dydt = y(2); 1000*(1-y(1)2)*y(2)-y(1);Now use the ode15s function to solve the problem with the initial conditionvector of 2; 0, but a time interval of 0 3000. For scaling reasons, plotjust the first component of y(t).现在用ods15s求解具有初值向量2;0和积分区间0,3000上的初值问题。为尺度原因,仅画出的第一分量。t,y = ode15s(vdp1000,0 3000,2; 0);plot(t,y(:,1),-);title(Solution of van der Pol Equation

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1