Event function not halting integration
Mostra commenti meno recenti
My Event function looks like this. It is meant to stop the integration of my ODE45 solver function when Xconcentration <= 20. It does this for the first couple of instances, but then when Xconcentration drops below 20 again, it does not halt the integration, even as Xconcentration gradually decreases towards 0. Why would it work for the first ~40 times but not the rest? Any help would be great.
function [value,isterminal,direction] = TransferEvent(t, Xconcentration)
VAL = 1;
for bb = 33:11:121
if Xconcentration(bb) <= 20 || Xconcentration(bb) >= 30
VAL = 0;
end
end
value = VAL; % The value that we want to be zero
isterminal = 1; % Halt integration
direction = 0; % The zero can be approached from either direction
end
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Ordinary Differential Equations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!