% An example from C. Marriott and C. DeLisle, Effects of % discontinuities in the behavior of a delay differential % equation, Physica D, 36 (1989), pp. 198-206. % The parameter state = +1 if ylag >= -0.427, -1 otherwise. % With this definition of history, state is initially +1. state = +1; opts = ddeset('Events','exam7e'); sol = dde23('exam7f',12,0.6,[0, 120],opts,state); while sol.x(end) < 120 fprintf('Restart at %5.1f.\n',sol.x(end)); state = - state; sol = dde23('exam7f',12,sol,[sol.x(end), 120],opts,state); end plot(sol.x,sol.y); title('Figure 7. Marriott-DeLisle Controller Problem') xlabel('Restart each time y(t - 12) = -0.427.');