求解Matlab中的ODES,6:ODE45
从系列:解决MATLAB中的ODES
ODE45通常是ODE求解器中选择的功能。它比较订单的方法四和五的方法以估计误差并确定步长。ODE45是如此准确,以至于其默认行为是使用其插值来在中间点提供结果。
Related MATLAB code files can be downloaded from MATLAB Central
MATLAB和SIMULINK中最常用的ODE求解器是Ode45。金宝app它基于1980年英国数学家JR Dormand和PJ Prince发表的方法。基本方法是第五顺序。错误校正使用伴随订单四种方法。
TN的斜率与以前的成功步骤相同,首先与最后一个剩余的相同。然后,在1/5 h,3/10h,4/5h,8/9h,然后在Tn Plus 1中还有五个斜率,然后在Tn Plus 1上。这六个斜率,它们的线性组合用于产生Yn Plus 1。
The function is evaluated at tn plus 1 and yn plus 1 to get a seventh slope. And then linear combinations of these are used to produce the error estimate.
Again, if the error estimate is less than the specified accuracy requirements the step is successful. And then that error estimate is used to get the next step size. If the error is too big, the step is unsuccessful and that error estimate is used to get the step size to do the step over again.
If we want to see the actual coefficients that are used, you can go into the code for ODE45. There's a table with the coefficients. Or you go to the Wikipedia page for the Dormand-Prince Method and there is the same coefficients.
顺便说一句,这是关于高阶runge-kutta方法的有趣事实。经典的runge-kutta每个步骤需要四个函数评估才能获取订单四。Dormand-Prince每步需要进行六项功能评估才能获得第五次订单。您不能仅通过五个函数评估获得订单五。然后,如果我们要尝试实现更高阶段,则每步将需要更多的功能评估。
让我们使用ode45将E计算为t。y素数等于y。我们可以通过提供称为TSPAN的参数来要求输出。零,步骤为0.1至1。如果我们将其作为输入参数求解以求解此微分方程并在这些点处获取输出,我们将其恢复为输出。现在,这是该点的微分方程解决方案的近似值。
如果我们绘制它,这是这些点的解决方案。为了了解它的准确性,我们看到我们实际上将此结果降到了九位数字。ODE45非常准确。
Let's look at step size choice on our problem with near singularity, is a quarter. y0 is close to 16. The differential equation is y prime is 2(a-t) y squared. We let ODE45 choose its own step size by indicating we just want to integrate from 0 to 1. We capture the output in t and y and plot it.
Now, here, there's a lot of points here, but this is misleading because ODE45, by default, is using the refine option. It's only actually evaluating the function at every fourth one of these points and then using the interpolant to fill in in between. So we actually need a little different plot here.
该情节显示出了更好的情况。大点是ODE45选择评估微分方程的点。小点充满了插值。因此,大点是每第四点。精炼的选项说,大点相距太远,我们需要用插值填充。因此,这是连续的interlestolant行动。
The big dots are more closely concentrated as we have to go around the curve. And then, as we get farther away from the singularity the step size increases. So this shows the high accuracy of ODE45 and the automatic step size choice in action.
Here's an exercise. Compare ODE23 and ODE45 by using each of them to compute pi. The integral 4 over 1 plus t squared from 0 to 1 is pi. You can express that as a differential equation, use each of the routines to integrate that differential equation and see how close they get to computing pi.
Select a Web Site
选择一个网站以获取可用的翻译内容,并查看本地事件和优惠。根据您的位置,我们建议您选择:。
You can also select a web site from the following list:
如何获得最佳网站性能
选择中国网站(中文或英语)以获得最佳场地性能。其他Mathworks乡村网站未针对您所在的访问进行优化。
Americas
- América Latina(Español)
- Canada(English)
- United States(English)
Europe
Asia Pacific
- 澳大利亚(English)
- India(English)
- New Zealand(English)
- 中国
- 日本Japanese(日本語)
- 한국Korean(한국어)