How could I fix the error "Out of memory with ode45" ?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello!
I am trying to solve a system of ODEs based on Lotka-Volterra Predator-prey model with many variables. I got an error as follows.
" Out of memory. The likely cause is an infinite recursion within the program.
Error in ode45 (line 115) odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin); "
Thank you.
0 commentaires
Réponses (1)
Steven Lord
le 1 Juil 2020
Modifié(e) : Steven Lord
le 1 Juil 2020
My suspicion is that you're calling ode45 with a function handle as input from inside the function that you're passing into ode45.
function yprime = example557812(t, y)
sol = ode45(@example557812, [0 10], 1);
yprime = y;
end
In this case example557812 calls ode45 which calls example557812 which calls ode45 which calls example557812 which calls ode45 which calls example557812 which calls ode45 which calls ...
Split the function that calls ode45 and the function called by ode45 into two separate functions. The function called by ode45 can be a local function in the file (it doesn't have to be its own file) but it shouldn't be the same as the function that calls ode45.
function sol = example557812_take2
sol = ode45(@fun, [0 10], 1);
plot(sol.x, sol.y)
end
function yprime = fun(t, y)
yprime = y;
end
1 commentaire
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!