function sol = exer5 % exer5, exer5f, exer5h of tutorial. % D.R. Wille' and C.T.H. Baker use Example 4 of DELSOL-- % a numerical code for the solution of systems of delay- % differential equations, Appl. Numer. Math., 9 (992) % 223-234 to illustrate a discontinuous history. DDE23 % treats any order discontinuity in the history as a % discontinuity in the solution itself, which is actually % the case for this example. opts = ddeset('Jumps',[-1,-4/5,-3/5,-2/5,-1/5]); sol = dde23(@exer5f,1,@exer5h,[0, 1],opts); plot(sol.x,sol.y) title('Example 4 of Wille'' and Baker.') xlabel('time t'); ylabel('y(t)'); %================================================ function yp = exer5f(t,y,Z) yp = Z; %================================================ function y = exer5h(t) y = (-1)^floor(-5*t);