Delay Differential Equation for arbitrary functions experiencing delay

Hello everyone and Hope yoo had a nice weekend and have a great one
I have this system of equations
dy1/dt = 2t + y1(t - tau2) + y2 + g(t - tau1)
dy2/dt = 3t + f(t - tau1)
I want to solve this system using dde23. I already know this function but my problem is, I have already f(t) and g(t) as vectors obtained by another mfile and I do not know how to apply the delay to them here. I have uploaded the f, g and t data.
history can be [1;0] or anything else and tau1 = 1 and tau2 = 0.2;
thanks in advance for your precious time devoting to this.

Answers (1)

Hi Proman,
As per my understanding, you are trying to solve a system of delay differential equations (DDEs) "dde23" in MATLAB, with f(t) and g(t) as vectors.
To solve the system of DDEs, refer to the following steps:
  • Interpolate f(t) and g(t) using the "interp1" MATLAB function to create continuous functions from your discrete data
f_interp = @(t) interp1(t, f, t, 'linear', 'extrap');
g_interp = @(t) interp1(t, g, t, 'linear', 'extrap');
  • Define function that describes the system using these interpolated functions
function dydt = dde_system(t, y, Z)
tau1 = 1;
tau2 = 0.2;
y1_tau2 = Z(:,1); % y1(t - tau2)
dydt = zeros(2,1);
dydt(1) = 2*t + y1_tau2 + y(2) + g_interp(t - tau1);
dydt(2) = 3*t + f_interp(t - tau1);
end
  • Specify the delays (tau1 = 1, tau2 = 0.2) and initial conditions
% Delays
lags = [1, 0.2];
% Initial conditions
history = @(t) [1; 0]; % History function
  • Use dde23 to compute the solution over a specific time span
sol = dde23(@dde_system, lags, history, [0, 10]);
Refer to the following documentation for more information on "interp1" function:
Refer to the following documentation for more information on "dde23" function:
Hope this helps!

Categories

Find more on Mathematics in Help Center and File Exchange

Products

Release

R2019b

Asked:

on 27 Sep 2021

Answered:

on 30 Oct 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!