Filter löschen
Filter löschen

Keep a for loop running when ODE gives an error

2 Ansichten (letzte 30 Tage)
MiguelMauricio
MiguelMauricio am 30 Sep. 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

Akzeptierte Antwort

Grzegorz Knor
Grzegorz Knor am 30 Sep. 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

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements 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!

Translated by