Code covered by the BSD License  

Highlights from
Tutorial on solving DDEs with DDE23

  • exam1
  • exam1
  • exam2
  • exam2
  • exam3
  • exam3
  • exam4
  • exam4
  • exam5
  • exam5
  • exam6 This is a demonstration problem for CTMS/BD in
  • exam6 This is a demonstration problem for CTMS/BD in
  • exam7 An example from C. Marriott and C. DeLisle, Effects
  • exam7 An example from C. Marriott and C. DeLisle, Effects
  • exam8 This is the suitcase problem from Suherman, et al.,
  • exam8 This is the suitcase problem from Suherman, et al.,
  • exer1 Example 1 of K.W. Neves, Automatic integration
  • exer1 Example 1 of K.W. Neves, Automatic integration
  • exer2 Example of J.D. Farmer, Chaotic Attractors of an
  • exer2 Example of J.D. Farmer, Chaotic Attractors of an
  • exer3 Wheldon's model of chronic granuloctic leukemia
  • exer3 Wheldon's model of chronic granuloctic leukemia
  • exer5
  • exer5
  • exer6 Sample problem of ARCHI manual. The absolute error
  • exer6 Sample problem of ARCHI manual. The absolute error
  • exer7 Marchuk immunology model of E. Hairer, S.P. Norsett, and
  • exer7 Marchuk immunology model of E. Hairer, S.P. Norsett, and
  • prob1 This system of ODE's is taken from 'An Introduction to Nuermcial Methods
  • prob1 This system of ODE's is taken from 'An Introduction to Nuermcial Methods
  • prob2 This problem considers a cardiovascular model, which can be found in
  • prob2 This problem considers a cardiovascular model, which can be found in
  • prob2b This problem considers a cardiovascular model, which can be found in
  • prob2b This problem considers a cardiovascular model, which can be found in
  • prob3 This problem is epidemic model due to Cooke, more information can be
  • prob3 This problem is epidemic model due to Cooke, more information can be
  • prob4 This problem is an epidemic model due to Cooke et alia, more information
  • prob4 This problem is an epidemic model due to Cooke et alia, more information
  • prob5 This problem population growth model due to Cooke et alia, more information
  • prob5 This problem population growth model due to Cooke et alia, more information
  • View all files

Tutorial on solving DDEs with DDE23

by

 

22 Aug 2003 (Updated )

Solving delay differential equations with DDE23. Tutorial + Examples.

exam4
function sol = exam4
% Infectious disease model of E. Hairer, S.P. Norsett, 
% and G. Wanner, Solving Ordinary Differential Equations 
% I, Springer-Verlag, Berlin, 1987, p. 295.  The maxima 
% of the solution components are located by finding where 
% the first derivative vanishes.  A maximum occurs when 
% the first derivative goes from a positive to a negative 
% value, so we tell DDE23 that we are interested only in 
% zeros for which the function decreases through zero.

% Copyright 2002, The MathWorks, Inc.

options = ddeset('Events',@exam4e);
sol = dde23(@exam4f,[1, 10],[5; 0.1; 1],[0, 40],options);

% Separate the various kinds of events and the solution 
% values then. ie = 1,2,3 according to which component 
% of the solution has a maximum.  Local variables are 
% used for clarity.
xe = sol.xe;
ye = sol.ye;
ie = sol.ie;
n1 = find(ie == 1);
x1 = xe(n1);
y1 = ye(1,n1);
n2 = find(ie == 2);
x2 = xe(n2);
y2 = ye(2,n2);
n3 = find(ie == 3);
x3 = xe(n3);
y3 = ye(3,n3);

figure
plot(sol.x,sol.y,'k',x1,y1,'rs',x2,y2,'rs',x3,y3,'rs')
title('Infectious disease model from Hairer et alia.')
xlabel('Maxima are indicated by red squares.')

%-----------------------------------------------------------------------

function yp = exam4f(x,y,Z)
%EXAM4F  The derivative function for the Example 4 of the DDE Tutorial.
ylag1 = Z(:,1);
ylag2 = Z(:,2);
yp = [ -y(1)*ylag1(2) + ylag2(2)
        y(1)*ylag1(2) - y(2)
        y(2) - ylag2(2)          ];

%-----------------------------------------------------------------------

function [value,isterminal,direction] = exam4e(x,y,Z)
%EXAM4E  The event function for the Example 4 of the DDE Tutorial.

% Maxima occur where the first derivatives vanish.
value = exam4f(x,y,Z);
isterminal = zeros(3,1);
direction = -ones(3,1);

Contact us