Is it possible to use an anonymous function as an event function in Matlab. What I want to do is basically
opt = odeset('Events', @(t,y) (deal(y(end)-t^2,1,0)));
[T,Y] = ode45(@odefun,[tstart tend],y0,opt);
However, this returns an error complaining that the number of outputs to deal must be matched exactly. Is there some other way to make the anonymous function return multiple arguments?