I want to halt ode execution and save the output after one of the functions drops below a certain bound. I'm trying to do this with odeset('Events',@events) as follows
function [sol,soln] = fullSScollHM8 % set parameters
options = odeset('Events',@events); sol2 = ode15s(@fullSSfunc,[t0,tf],init,options); endfunction dy = fullSSfunc(~,y) dy(1) = ... dy(7) = ...endfunction [value,isterminal,direction] = events(~,y) value = y(7) - 10^(-10); % detect when y(7) gets too low
isterminal = 1; % halt integration
direction = 0; % any which way
end
But if I output value, the code continues to run when y(7) drops below 10^(-10) because value is never zero. It seems like it should be straightforward to define an 'Event' within odeset not with a zero but rather a threshold. Can someone help me please?
Best Answer