I've worked with ode events in MATLAB many times now; however, I can't seem to figure out why the following events function not only won't trigger, but it's not even being evaluated:
options = odeset('RelTol',1e-12,'Events', @posEventsFcn);
[~,~,~,pos3i,~] = ode113(@findnegBt, tspan, [pos2(i,1) pos2(i,2) pos2(i,3)]', options);
function [position,isterminal,direction] = posEventsFcn(~,y)
position = y(3);
isterminal = 1;
direction = 0;
The y(3) and pause never occur, leading me to believe this function is never evaluated.
Furthermore, if I print the y(3) values in the derivative-finding function ( @findnegBt ), I am able to watch the values change from positive/negative, approach zero, and become negative/positive - which to my understanding should trigger the events function (a change in sign).
Question: What reasons might there be for this event to not trigger, much less never be evaluated?
Note: I've already attempted reducing the integration tolerance and other parameters, but that didn't fix anything.
Thanks for your time and efforts!