ode for different time intervals

5 ビュー (過去 30 日間)
Nivedhitha S
Nivedhitha S 2019 年 8 月 17 日
回答済み: Sam Johnson 2020 年 8 月 23 日
Hello all,
I have a question regarding applying ode for different time intervals within a set of differential equations. For eg, I have a set of 6 DE of which few eqns has to be integrated over the entire tspan while 1 equation has to be active only after acertain time point (something like two phases of experiment). How can i achieve that in matlab? Should i create nested functions or should i create separate functions and call them in a mian file? I am totally confused. Since few parameters are interdependent I am unable to create separate functions for separate eqns. Please give me some sugestions.

採用された回答

Walter Roberson
Walter Roberson 2019 年 8 月 17 日
It is valid to test
if t < stoptime1
inside an ode function. However, you need to make two calls to ode45
[t1, y1] = ode45(f, [0, stoptime1], y0) ;
[t2, y2] = ode45(f, [stoptime1,stoptime2], y1(end, :)) ;

その他の回答 (1 件)

Sam Johnson
Sam Johnson 2020 年 8 月 23 日
[t,x] = ode45(@(t,x) x.*(4-x), [0,5], -2.0:4.0:6.0);
plot(t,x)

カテゴリ

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