Keep a for loop running when ODE gives an error

1 visualización (últimos 30 días)
MiguelMauricio
MiguelMauricio el 30 de Sept. de 2011
Hi,
I am trying to run a code for sensitivity analysis on initial conditions and parameters of a process. To evaluate the different inputs I use a for loop and I solve an ODE in each iteration. The problem is that some of the combination of parameters and initial conditions cannot be solved and, when this happens, ode45 (and ode15s) stops the script. I really would wish that the for loop could keep on running after storing a warning output from the odesolver. Do you know if this is possible? I include a pseudocode of the script:
% mxn A matrix contaning m sampling combinations of n input parameters
for i=1:m
input=A(i,:)
solution(i)=odesolver(@function,t,input)
end
So the question is if I could do something so that the for loop keeps running even if the odesolver gives an error message. Thank you,
Miguel

Respuesta aceptada

Grzegorz Knor
Grzegorz Knor el 30 de Sept. de 2011
% mxn A matrix contaning m sampling combinations of n input parameters
for i=1:m
input=A(i,:)
try
solution(i)=odesolver(@function,t,input)
catch ME
warning(...)
end
end

Más respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by