ODE Solver Running Very "Slowly"
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
"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
0 Kommentare
Antworten (1)
Star Strider
am 25 Okt. 2023
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
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
.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

