simulation of dde problem
10 views (last 30 days)
Show older comments
Good evening sir i am trying to find simulation of dde model problem but i got error. I. request you sir please help me by resolving this error
beta = 1.9;
a1 = 0.3;
a2 = 0.2;
gamma1= 0.01;
gamma2= 0.01;
gamma3= 0.05;
mu= 0.05;
tau =14;
N=1;
d1 = 0.04;
d2 = 0.02;
ddeSEIQR = @(t,y,Z)[N-beta*y(1)*y(3)/N-mu*y(1);...
(beta*y(1)*y(3)/N)-beta*exp(-mu*tau)*Z(1,1)*Z(3,1)/N-a1*y(2)-gamma1*y(2)-mu*y(2);...
beta*exp(-mu*tau)*Z(1,1)*Z(3,1)/N-a2*y(3)-gamma2*y(3)-d1*y(3)-mu*y(3);...
a1*y(2)+a2*y(3)-d2*y(4)-gamma3*y(4)-mu*y(4);...
gamma1*y(2)+gamma2*y(3)+gamma3*y(4)-mu*y(5)];
sol = dde23(ddeSEIQR,[14,1],[0.999,0,0.001,0,0],[0,200] ) ;
figure;
plot(sol.x,sol.y(1,:))
hold on
plot(sol.x,sol.y(2,:),'-')
hold on
plot(sol.x,sol.y(3,:),'--')
hold on
plot(sol.x,sol.y(4,:),'--')
hold on
plot(sol.x,sol.y(5,:),'--')
hold off
title('Equilibrium points for SEAIQR Model');
label ('time(days)');
label('solution y');
legend('S', 'E','I', 'Q','R');
ERROR:
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Error in
SEIQR_dde>@(t,y,Z)[N-beta*y(1)*y(3)/N,-mu*y(1);(beta*y(1)*y(3)/N)-beta*exp(-mu*tau)*Z(1,1)*Z(3,1)/N-a1*y(2)-gamma1*y(2)-mu*y(2);beta*exp(-mu*tau)*Z(1,1)*Z(3,1)/N-a2*y(3)-gamma2*y(3)-d1*y(3)-mu*y(3);a1*y(2)+a2*y(3)-d2*y(4)-gamma3*y(4)-mu*y(4);gamma1*y(2)+gamma2*y(3)+gamma3*y(4)-mu*y(5)]
(line 15)
ddeSEIQR = @(t,y,Z)[N- beta*y(1)*y(3)/N -mu*y(1);
Error in dde23 (line 228)
f0 = feval(ddefun,t0,y0,Z0,varargin{:});
Error in SEIQR_dde (line 21)
sol = dde23(ddeSEIQR,[14,1],[0.999,0,0.001,0,0],[0,200] ) ;
4 Comments
Torsten
on 10 Aug 2022
what is [14,1] and how did i take ?
Did you read the documentation of dde23 ?
14 and 1 are the lags in your differential equations.
I wonder why you specified two lags because in your equations, you only refer to the first (14) with the terms
Z(1,1) (which means y1(t-14)) and
Z(3,1) (which means y3(t-14)).
Answers (1)
Pavl M.
on 6 Dec 2024 at 21:22
Edited: Pavl M.
on 6 Dec 2024 at 22:22
% I've actually found the specific ammendment-corregendum-initial
% enreachment and SOLVED it:
clc
clear all
close all
tol = 1e-07;
rand('state',1)
diary on
diary('PavW.txt')
disp(' ');
disp(' * * * * * * * * * * * *')
disp(' * Start *');
disp(' * * * * * * * * * * * *')
function h = history(t)
h = t;
end
function [position,isterminal,direction] = zeroEventsFcn(t,y,ydelay)
position = y(5);
isterminal = 1;
direction = 0;
end
beta = 1.9;
a1 = 0.3;
a2 = 0.2;
gamma1= 0.01;
gamma2= 0.01;
gamma3= 0.05;
mu= 0.05;
tau =14;
N=1;
d1 = 0.04;
d2 = 0.02;
ddeSEIQR = @(t,y,Z)[N-beta*y(1)*y(3)/N-mu*y(1);...
(beta*y(1)*y(3)/N)-beta*exp(-mu*tau)*Z(1,1)*Z(3,1)/N-a1*y(2)-gamma1*y(2)-mu*y(2);...
beta*exp(-mu*tau)*Z(1,1)*Z(3,1)/N-a2*y(3)-gamma2*y(3)-d1*y(3)-mu*y(3);...
a1*y(2)+a2*y(3)-d2*y(4)-gamma3*y(4)-mu*y(4);gamma1*y(2)+gamma2*y(3)+gamma3*y(4)-mu*y(5)];
delays1 = [14,1];
delays2 = 15;
%sol = dde23(@ddefun,delays,history,tspan);
opts = ddeset(Events=@zeroEventsFcn);
sol = dde23(ddeSEIQR,delays1,[0.999,0,0.001,0,0],[0 200],opts);
figure;
plot(sol.x,sol.y(1,:))
hold on
plot(sol.x,sol.y(2,:),'-',sol.xe,sol.ye(2,:),"o")
hold on
plot(sol.x,sol.y(3,:),'--')
hold on
plot(sol.x,sol.y(4,:),'--')
hold on
plot(sol.x,sol.y(5,:),'--',sol.xe,sol.ye(5,:),"o")
hold off
title('Equilibrium points for SEAIQR Model with events');
xlabel('time [days]');
ylabel('solution y');
legend('S','E','I','Q','R');
diary off
%P.S. If you liked my now and preceding work, donate:
% https://skrill.me/rq/Pavlo/95/USD?key=K71IB_VKnU2jh2rNaaUhANSs3Jf
% ✅ Bringing DeFi(advantage of P2P: certainty in path), opportunities to the global majority,
% the labour market remains very tight
%™®©
0 Comments
See Also
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!