simulation of dde problem
조회 수: 9 (최근 30일)
이전 댓글 표시
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
Torsten
2022년 8월 10일
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)).
답변 (1개)
Pavl M.
2024년 12월 6일
편집: Pavl M.
2024년 12월 6일
% 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
참고 항목
카테고리
Help Center 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!