ODE Solver Running Very "Slowly"
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
"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 comentarios
Respuestas (1)
Star Strider
el 25 de Oct. de 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 comentarios
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

