SIRE with vaccine model
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Campbell Gorrie
le 24 Oct 2021
Réponse apportée : Alan Stevens
le 24 Oct 2021
%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
0 commentaires
Réponse acceptée
Alan Stevens
le 24 Oct 2021
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Web Services dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!