フィルターのクリア

solving a ODE using ode45 or etc. with certain number of timestepping

1 回表示 (過去 30 日間)
Hossein
Hossein 2015 年 6 月 16 日
回答済み: Walter Roberson 2015 年 6 月 16 日
Hi everybody,
I want to solve an ODE using Adams-Bashforth 4th order method which needs the initial values of previous steps so I need to solve the ODE 4 or 5 times using other method such as Runge-Kutta. As far as ode45 is an adaptive time-stepping solver in order to save computation time has anybody any suggestion how can I make solver to do solving for just 4 or 5 times and then break it?
many tnx in advance.

回答 (2 件)

Torsten
Torsten 2015 年 6 月 16 日
Use the Runge-Kutta method to calculate 3 data points in addition to the initial condition:
for i = 1:3
k1 = f(t,y);
k2 = f(t+h/2, y+h/2*k1);
k3 = f(t+h/2, y+h/2*k2);
k4 = f(t+h, y+h*k3);
y = y+h/6*(k1 + 2*k2 + 2*k3 + k4);
t = t + h;
yn(1,i+1) = y;
end
Best wishes
Torsten.
  2 件のコメント
Hossein
Hossein 2015 年 6 月 16 日
dear torsten tnx for the answer but it can not help me because I prefer using ode45 routin based on some oder problems and complexity and my question refers to adjusting number of steps just in ode45.
Torsten
Torsten 2015 年 6 月 16 日
Well, you can set h, 2*h and 3*h as output times for the solution from ODE45 and feed your Adams routine with these values.
Best wishes
Torsten.

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


Walter Roberson
Walter Roberson 2015 年 6 月 16 日
Configure an OutputFcn option that tests the number of function calls from the information structure passed in and sets the termination flag appropriately.

カテゴリ

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