How can I combine the Exposed population and the Susceptible population to make a total population?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi I'm new to matlab, any advice would be great! I'm trying to combine my Suceptible population with my Exposed population, so that I can have a total population. I'm not sure how to do this. Here is part of my code.
%initial conditions
S= N-1;
E=0;
I=1;
CI =0;
y0=[S;E;I;CI];
tspan=[0:Cstop]; %simulate for 35 years (1923-1958)
%pars=[beta,alpha,mu,gamma,delta];
[t,y1]=ode45(@SEICI_rhs,tspan,y0,[],pars);
yi=y1(end,:);
tspan=[Cstop:136]; %simulate for 100 years (1958-2058)
pars=[0,alpha,mu,gamma,delta];
[t,y2]=ode45(@SEICI_rhs,tspan,yi,[],pars);
CDeaths=[y1(:,4); y2(2:end,4)]; % The fourth variable entry is cummulative deaths
Deaths=CDeaths(2:end)-CDeaths(1:end-1);
Susceptibles=[y1(2:end,1); y2(2:end,1)];
Expo=[y1(:,2); y2(2:end,2)];
Exposed=Expo(2:end)+Expo(1:end-1);
Infectious=[y1(2:end,3); y2(2:end,3)];
Totpop=
0 Kommentare
Antworten (1)
Abhinaya Kennedy
am 3 Apr. 2024
Hi Layla,
To calculate the total population at each time step, sum the "Susceptible", "Exposed" (aligned by offsetting by 1 for correct size), and "Infectious" compartments:
Assuming "Susceptibles" and "Exposed" represent the total counts in each compartment over time and assuming "y1" and "y2" include all compartments correctly, use the following code.
Note: This assumes you want to include "Infectious" in the total population calculation. If there are other compartments like "Recovered", you would need to add those as well
TotalPopulation = Susceptibles + Exposed(2:end) + Infectious;
This assumes deaths are accounted for in the compartment "transitions" and doesn't include a "Recovered" compartment. If your model handles deaths differently or includes additional compartments, adjust accordingly.
If you need to include cumulative deaths differently, adjust for that too. For example, if deaths reduce the total population and are not already accounted for:
TotalPopulationAdjusted = TotalPopulation - CDeaths(2:end); % Adjust based on how deaths are tracked
Hope this helps!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Curve Fitting Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!