ODE Solver Running Very "Slowly"
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
"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 commentaires
Réponses (1)
Star Strider
le 25 Oct 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 commentaires
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

