Hi Yi-xia Liu,
The values of variables “te”,”ye” and “ie” are empty when the event is set to terminate the integration at “t=tspan(end)”. I have created an example to verify this for which the code is provided below:
options = odeset('Events',@events,'OutputFcn',@odeplot,'OutputSel',1,...
[t,y,te,ye,ie] = ode23(@f,[tstart tfinal],y0,options);
yout = [yout; y(2:nt,:)];
plot(teout,yeout(:,1),'ro')
title('Ball trajectory and the events');
function [value,isterminal,direction] = events(t,y)
The example models a bouncing ball with exactly one bounce and the ball touches the ground at t=4. The event function is configured to terminate the integration when height=0 which occurs at t=4. The tspan(end) is also set to 4.
The output from the code is:
By putting a breakpoint in the code after calling “ode23” we can check that the variables “te”, “ye” and “ie” are empty.
I hope this helps!