In How do I pass out extra parameters using ODE23 or ODE45 from the MATLAB ODE suite? the "MathWorks Support Team" suggests using a persistent
variable to pass out extra parameters using ode45
from the MATLAB ODE suite.
However, what if an integration failed and solver will call your function for the previous time step? The ode45
solver uses an adaptive time step, and sometimes integration can fail, so the solver automatically decreases time step, and "has to go back."
Is "MathWorks Support Team" wrong in their suggestion of using a persistent
variable? I see that the 'OutputFcn'
method can be used to pass out extra parameters, but I do not know how to use it. Could you give me an outline or example code using the 'OutputFcn'
method to detect failed steps / flag etc. to give the correct extra parameters? If I use the 'OutputFcn'
method, is a global
variable needed?
outputFcn
for many attempts but i do not have a general outline on how to use it and if how to define or which to define a global variable/s. Can you give me an outline or example code on how to achieve this? – Ka-Wa Yip