Solution of a nonlinear DDE with the Matlab function dde23
Download demo file:
Code of the demo file:
function dde23demo
% This is a simple example that illustrates the solution of a nonlinear system of delay differential equations (DDEs) with the Matlab function dde23.
%
% The DDE x'(t) = f(x(t))+BKx(t)+Bx(t-d) is solved on [0, 100]
% with history x(t) = [1;1;1] for t <= 0 and where f(x(t)) is given by the Lorenz system
%
% The DDE and the history are specified in the subfunctions DDEX1DE and DDEX1HIST, respectively.
d=10; % Value of the delay d
sol = dde23(@ddex1de,d,@ddex1hist,[0, 100]);
figure;
plot(sol.x,sol.y)
xlabel('time t');
ylabel('solution y');
% --------------------------------------------------------------------------
function s = ddex1hist(t)
% Constant history function for DDEX1.
s = ones(3,1); % The Lorenz system is a three-dimensional system
% --------------------------------------------------------------------------
function dxdt = ddex1de(t,x,Z)
% Differential equations function for DDEX1
% Lorenz system is used for f(x).
sigma=10; beta=8/3; rho=28;
B=eye(3);
K=eye(3);
% B=zeros(3,3); % B=0 corresponds to the classical Lorenz dynamics
% without time-delayed feedback
xlag = Z(:,1);
dxdt = [ sigma*(x(2)-x(1));
x(1)*(rho-x(3))-x(2);
x(1)*x(2)-beta*x(3)]+ B*K*x + B*xlag;