ODE Solver Running Very "Slowly"

2 ビュー (過去 30 日間)
성주
성주 2023 年 10 月 25 日
回答済み: Star Strider 2023 年 10 月 25 日
"Hi, I'm attempting to numerically solve differential equations using ode45. I'm aiming to obtain results within the 0 to 100-second range. However, the computation is taking an excessively long time, and I haven't received any results yet. Are there any options I can employ to expedite the process?"
t= linspace(0,100,1000)
[t,y]= ode45(@f,t,[0.785398163 0]);
plot(t, y(:, 1))
function dydt = f(t,y)
dydt = [(2.17147)*y(2); -3.14352E+14*(y(2)) - 9.97162E+15*sin(2*y(1))];
end

回答 (1 件)

Star Strider
Star Strider 2023 年 10 月 25 日
Your system is ‘stiff’ because the parameters span several orders-of-magnitude. Use a ‘stiff’ solver such as ode15s instead —
t= linspace(0,100,1000);
tic
[t,y]= ode15s(@f,t,[0.785398163 0]);
toc
Elapsed time is 0.106661 seconds.
figure
plot(t, y(:, 1))
figure
plot(t, y(:, 1))
xlim([0 1])
function dydt = f(t,y)
dydt = [(2.17147)*y(2); -3.14352E+14*(y(2)) - 9.97162E+15*sin(2*y(1))];
end
.

カテゴリ

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