简体   繁体   English

Matlab ode45如何工作

[英]Matlab How Does ode45 Work

I asked a question regarding how the matlabFunction worked ( here ), which spurred a question related to the ode45 function. 我问了一个关于matlabFunction如何工作的问题( 这里 ),这引发了一个与ode45函数相关的问题。 Using the example I gave in my post on the matlabFunction, when I pass this function through ode45, with some initial conditions, does ode45 read the derivative -s.*(xy) as approximating the unknown function x; 使用我在matlab函数中发布的示例,当我通过ode45传递此函数时,有一些初始条件,ode45读取导数-s。*(xy)作为近似未知函数x; the same thing being said of -y+r.*xx.*z and y, and -b.*z+x.*y and z? 同样说的是-y + r。* xx。* z和y,以及-b。* z + x。* y和z? More specifically, we have the 更具体地说,我们有

matlabFunction([s*(y-x);-x*z+r*x-y; x*y-b*z],
            'vars',{t,[x;y;z],[s;r;b]},'file','Example2');

and then we use 然后我们使用

[tout,yout]=ode45(@(t,Y,p)  Example2(t,Y,[10;5;8/3]),[0,50],[1;0;0]);

To approximately solve for the unknown functions x,y, and z. 近似求解未知函数x,y和z。 How does ode45 know to take the functions, which are defined as variables, [x;y;z] and approximate them? ode45如何知道将函数定义为变量[x; y; z]并近似它们? I have an inkling of a feeling that my question is rather vague, but I would just like to know the connection between these things. 我有一种感觉,我的问题很模糊,但我想知道这些事情之间的联系。

The semantics of your commands is that x'(t)=s*(y(t)-x(t)), y'(t)=-x(t)*z(t)+r*x(t)-y(t), and z'(t)=x(t)*y(t)-b*z(t), with the constants you have given for s, r, and b. 你的命令的语义是x'(t)= s *(y(t)-x(t)),y'(t)= - x(t)* z(t)+ r * x(t) -y(t)和z'(t)= x(t)* y(t)-b * z(t),其中给出了s,r和b的常数。 MATLAB will follow the commands you have given and compute a numerical approximation to this system. MATLAB将遵循您给出的命令并计算该系统的数值近似值。 I am not entirely sure what you mean by your question, 我不完全确定你的问题是什么意思,

How does ode45 know to take the functions, […] and approximate them? ode45如何知道这些功能,[...]并近似它们?

That is exactly what you told it to do, and it is the only thing ode45 ever does. 这正是你告诉它要做的事情,而且这是ode45唯一ode45事情。 (By the time you call ode45 , the names x, y, z are completely irrelevant, by the way. The function only cares for a vector of values.) If you are asking about the algorithm behind approximating the solution of an ODE given this way, you can easily find any number of books and lectures on the topic using google or any other search engine. (当你调用ode45 ,名字x,y,z完全不相关,顺便说一下。该函数只关心值的向量。)如果你问的是近似于ODE的解决方案背后的算法给出了这个方式,您可以使用谷歌或任何其他搜索引擎轻松找到有关该主题的任意数量的书籍和讲座。

You may be interested in the function odeToVectorfield , by the way, which simplifies getting these functions from a differential equation written in more traditional form. 顺便说一句,您可能对函数odeToVectorfield感兴趣,这简化了从更传统形式编写的微分方程中获取这些函数的过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM