ODE Event - Terminal
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello. I have a problem with my ode event. I want it to stop integration if one of the variables to be integrated is a complex number or negative. Let's call it y.
Inside the ode function I take care of this in my second event: values(2) = (isreal(y)==1), according to help the event would happen when value(i) is 0.
isterminal = [1 1]; % both events are terminal
direction = zeros(size(values)); % the zero can be approached from either direction
So it checks if is complex and if it is not then it ignores and continues to run. Problem is that there seems to be an internal loop in ode, see example below from a single integration step:
values =
1.00000000000000e+000 1.00000000000000e+000 % nothing happens, continue to integrate
y =
284.083918031355e-003 <--------------- event checked correctly, this is not complex
y =
284.083918031355e-003
y=
284.083918031355e-003
y =
284.083918031355e-003
y =
284.083917608037e-003
y =
284.083918031355e-003
y =
284.345056013165e-003 + 708.567318304124e-006i <------------------ ode runs several times without checking for the event until it reached a complex number and the code crashes
What is the problem? Is there an option to force matlab to check for events even in these internal ode loops (within the same integration step)?
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Ordinary Differential Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!