フィルターのクリア

How to know the step time inside the function that integrated by ode45?

3 ビュー (過去 30 日間)
Mohamed Aburakhis
Mohamed Aburakhis 2016 年 6 月 24 日
コメント済み: Walter Roberson 2016 年 6 月 25 日
I have
x0=1;
[t,x] = ode45(@My_Fun,[0:0.01:10],x0);
and My_Fun is
function x_dot =My_Fun(t, x)
Here %%%
%%I want to know the instantaneous step time %%%
What are t(now) and t(next) %%%
x_dot(1)=2/m-x;
  1 件のコメント
James Tursa
James Tursa 2016 年 6 月 25 日
Why do want this info? I.e., what would you do with it?

サインインしてコメントする。

採用された回答

Roger Stafford
Roger Stafford 2016 年 6 月 25 日
編集済み: Walter Roberson 2016 年 6 月 25 日
You might be interested in a comment made in
“If tspan contains two elements, [t0 tf], then t contains the internal evaluation points used to perform the integration.” It depends on whether you believe this in a literal sense or that it is merely an "approximate" truth.

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 6 月 25 日
You cannot know the t of the next step. ode45() uses adaptive time steps, so the next time step will depend upon will depend upon the outcome of this step. Also, if your x is not a scalar, then the next ode45 call might have the same time as the current one, but with different boundary conditions (x), so that it can explore the change along the other dimensions.
  1 件のコメント
Walter Roberson
Walter Roberson 2016 年 6 月 25 日
None of the ode* routines permit fixed time step. They do allow setting a guideline for the initial step, and they do allow setting the maximum step, but they do not allow the step size to be fixed.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by