Skip error message in solving multiple ODEs in a loop

1 view (last 30 days)
I am trying to solve a number of differential equations having the same form but varying parameters. E.g.:
for n=1:np % np= number of parameters & equations to be solved
[x(n),y(n)] = ode45(@dy/dx,xrange,[x0],foptions) %
end
function dy/dx
dy/dx=f(x,y,parameter(n))
end
whereas in each loop the value of parameter(n) changes. Now if Matlab ODE solver encounters an error in each step n, the program stops to work, although the previous solutions have been caluclated. Is there a way to recognize that an erros is occuring and skip that one specific step where the solver fails and go to the next step n+1 with parameter(n+1), and so on until the end?

Answers (0)

Community Treasure Hunt

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

Start Hunting!