how to modify code for distributed delay

I have a code, which gives a solution of a delay logistic equation with discrete delay.
tau = 1;
tspan = [0 20];
y0 = 0.5;
sol = dde23(@ddefunc, tau, y0, tspan);
% Plot the solution
figure;
plot(sol.x, sol.y, 'LineWidth', 2);
xlabel('Time (days)');
ylabel('Population');
legend('y');
% Define the delay differential equation
function g = ddefunc(t, y, Z)
r = 1.5;
y_tau = Z;
g = r * y * (1 - y_tau);
end
Now I want to modify my code for distributed delay as attached below.
Can someone guide me how to deal with distributed delay

 採用された回答

Torsten
Torsten 2024 年 8 月 16 日

1 投票

r = 1.5;
fun = @(t,x)[r*x(1)*(1-x(2));x(1)];
x0 = [0.5;0];
tspan = [0 20];
[t,x] = ode45(fun,tspan,x0);
plot(t,x(:,1))
grid on

4 件のコメント

William Rose
William Rose 2024 年 8 月 16 日
@Muhammad, @Torsten, nice answer.
Muhammad
Muhammad 2024 年 8 月 16 日
@William Rose,@Torsten Thank you for your response! However, I think there might be some confusion. My original question was about how to modify the delay logistic equation code to account for a distributed delay rather than a simple delay.
Torsten
Torsten 2024 年 8 月 16 日
編集済み: Torsten 2024 年 8 月 16 日
This is the solution for equation (1.6) with r=1.5 and x(0) = 0.5.
If you have something different in mind, you must post it.
Note that the second equation
dy/dt = x, y(0) = 0
gives
y(t) = integral_{tau=0}^{tau=t} x(tau) dtau
as solution, thus the integral in (1.6).
Muhammad
Muhammad 2024 年 8 月 17 日
Thank you for your clear response!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

質問済み:

2024 年 8 月 16 日

コメント済み:

2024 年 8 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by