function [distance_left,isterminal,direction] = end_of_race_event(t,y) % the race will go for 1/4 mile quarter_mile = 402.3; % [m] % assume that y(2) is the distance traveled distance_left = quarter_mile - y(2) ; % this is a terminal event -- the simulation should stop when the car % reaches a quarter mile isterminal = 1; % the direction in which the zero value is crossed does not matter direction = 0;