SIRE with vaccine model

조회 수: 1 (최근 30일)
Campbell Gorrie
Campbell Gorrie 2021년 10월 24일
답변: Alan Stevens 2021년 10월 24일
%Hey im just trying to graph S,I, R, E at the bottom but anytime i click run it comes up blank
function SEIR
N = 5185002;
v = 46.25;
b = v*2.2;
m=0.7
k= 30
a = 62.93;
function dF = rigid(t, x);
dF = zeros(8,1);
dF(1) = - b*(x(5)+x(6))*x(1)/N+k*x(7);
dF(2) =- b*m*(x(5)+x(6))*x(2)/N ;
dF(3) =b*(x(5)+x(6))*x(1)/N - (a)*x(3);
dF(4) =b*m*(x(5)+x(6))*x(2)/N - m*(a)*x(4);
dF(5) =(a)*x(3)-v*x(5);
dF(6) =m*((a)*x(4)-v*x(6));
dF(7) =v*x(5)-k*x(7);
dF(8)=v*m*x(6);
end
options = odeset('Refine', 10, 'RelTol', 1e-4);
[t,y] = ode45(@rigid, [0 1.5], [(5185000*0.3) (5185000*0.7) 1 1 0 0 0 0], options); .
S= y(1)+y(2);
E= y(3)+y(4);
I= y(5) +y(6);
R= y(7)+y(8)
plot(t,(y(1)+y(2)),t,(y(3)+y(4)),t,(y(4)+y(5)),t,(y(6)+y(7)))
title('SEIR model')
legend('S','E','I', 'R')
end

채택된 답변

Alan Stevens
Alan Stevens 2021년 10월 24일
Like this
tspan = [0 1.5];
options = odeset('Refine', 10, 'RelTol', 1e-4);
y0 = [5185000*0.3 5185000*0.7 1 1 0 0 0 0];
[t,y] = ode45(@rigid, tspan, y0, options);
S= y(:,1)+y(:,2);
E= y(:,3)+y(:,4);
I= y(:,5) +y(:,6);
R= y(:,7)+y(:,8);
plot(t,S,t,E,t,I,t,R)
title('SEIR model')
legend('S','E','I', 'R')
function dF = rigid(~, x)
N = 5185002;
v = 46.25;
b = v*2.2;
m=0.7;
k= 30;
a = 62.93;
dF = zeros(8,1);
dF(1) = - b*(x(5)+x(6))*x(1)/N+k*x(7);
dF(2) =- b*m*(x(5)+x(6))*x(2)/N ;
dF(3) =b*(x(5)+x(6))*x(1)/N - (a)*x(3);
dF(4) =b*m*(x(5)+x(6))*x(2)/N - m*(a)*x(4);
dF(5) =(a)*x(3)-v*x(5);
dF(6) =m*((a)*x(4)-v*x(6));
dF(7) =v*x(5)-k*x(7);
dF(8)=v*m*x(6);
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Web Services에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by