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.

exam8
function sol = exam8
% This is the suitcase problem from Suherman, et al.,
% Effect of Human Response Time on Rocking Instability 
% of a Two-Wheeled Suitcase, J. of Sound and Vibration, 
% Vol. 207 (5), 1997, 617-625. Event location is used to 
% find when the wheels impact the ground and when the 
% suitcase has fallen over. The parameter values are those
% used to generate Figure 3a in the reference.

% Copyright 2002, The MathWorks, Inc.

state = +1;
opts = ddeset('RelTol',1e-5,'AbsTol',1e-5,...
              'Events',@exam8e);
sol = dde23(@exam8f,0.1,[0; 0],[0 12],opts,state);  
ref = [4.516757065, 9.751053145, 11.670393497];
fprintf('\nKind of Event:                 dde23   reference\n');
event = 0;
while sol.x(end) < 12
   event = event + 1;
   if sol.ie(end) == 1
      fprintf('A wheel hit the ground.   %10.4f  %10.6f\n',...
              sol.x(end),ref(event));
      state = - state;
      opts = ddeset(opts,'InitialY',[ 0; 0.913*sol.y(2,end)]);
      sol = dde23(@exam8f,0.1,sol,[sol.x(end) 12],opts,state);
   else     
      fprintf('The suitcase fell over.   %10.4f  %10.6f\n',...
              sol.x(end),ref(event));
      break;
   end
end
figure
plot(sol.y(1,:),sol.y(2,:))
title('Suitcase problem.')
xlabel('\theta(t)')
ylabel('\theta''(t)')

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

function yp = exam8f(t,y,Z,state)
%EXAM8F  The derivative function for the Example 8 of the DDE Tutorial.
gamma = 0.248;
beta  = 1;
A = 0.75;
omega = 1.37;
eta = asin(gamma/A);
ylag = Z(:,1);
yp = [y(2); 0];
yp(2) = sin(y(1)) - state*gamma*cos(y(1)) - ...
        beta*ylag(1) + A*sin(omega*t + eta);

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

function [value,isterminal,direction] = exam8e(t,y,Z,state)
%EXAM8E  The event function for the Example 8 of the DDE Tutorial.
value = [y(1); abs(y(1))-pi/2];
isterminal = [1; 1];
direction  = [0; 0];

Contact us