The code is plotting $R_0$ against two parameters
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have been trying to run this code but it give me this error:
Error in Testing_1 (line 21)
[c,h] = contourf(alpha_3,alpha_1,R_0',levels);
%Basic Reproduction Number
alpha_m = 1/8.5; %Rate at which exposed men respectively become infectious
alpha_f = 1/22; %Rate at which exposed women respectively become infectious
tau_m = 1/8.5; %Rate at which infectious men respectively recover
tau_f = 1/21; %Rate at which infectious women respectively recover
beta_mm = 0.23; %Transmission probability from infectious men having sex with susceptible men
beta_ff = 0.18; %Transmission probability from infectious women having sex with susceptible women
beta_mf = 0.01; %Transmission probability from infectious men having sex with susceptible women
beta_fm = 0.18; %Transmission probability from infectious women having sex with susceptible men
alpha_1 = 0.01; %Modification parameters in reducing transmission
alpha_2 = 0.1; %Modification parameters in reducing transmission
alpha_3 = 1.5; %Modification parameters in reducing transmission
I_f = 27; %Population of infectious women
I_m = 28.22; %Population of infectious men
R_0 = (alpha_3 * beta_ff * tau_m + beta_mm * tau_f)/(2 * tau_f * tau_m) + sqrt(4*alpha_1*alpha_2*beta_fm*beta_mf*tau_f*tau_m + alpha_3^2*beta_ff^2*tau_m^2 - 2*alpha_3 * beta_ff * beta_mm * tau_f * tau_m + beta_mm^2 * tau_f^2)/(2 * tau_f * tau_m);
% plot
levels = (0:0.2:1.2);
[c,h] = contourf(alpha_3,alpha_1,R_0',levels);
clabel(c,h)
h.LineWidth = 2; % contour line width (up to you)
xlabel('\alpha_3');
ylabel('\alpha_1');
colormap(jet(numel(levels)-1));
colorbar('vert');
I will appreciate a response.
7 commentaires
Dyuman Joshi
le 24 Nov 2023
Modifié(e) : Dyuman Joshi
le 24 Nov 2023
It's not possible to draw a surface plot with scalar data.
You can see that in the answer below, Walter has defined alpha_1 and alpha_3 as grids, only then a surface plot is obtained.
Are you using a research paper as reference and trying to reproduce some results? If so, then please share additional information regarding it.
Réponses (1)
Walter Roberson
le 30 Oct 2023
I had to guess about the range of alpha_1 and alpha_3 that you wanted to plot.
The contour turns out solid color because the values of R_0 are mostly more than max(levels)
The surface is pretty boring except for a small area near the origin. And if you go too far from the origin then there is a part where the surface goes complex valued. So you would need to tell us what plot range to look at.
%Basic Reproduction Number
alpha_m = 1/8.5; %Rate at which exposed men respectively become infectious
alpha_f = 1/22; %Rate at which exposed women respectively become infectious
tau_m = 1/8.5; %Rate at which infectious men respectively recover
tau_f = 1/21; %Rate at which infectious women respectively recover
beta_mm = 0.23; %Transmission probability from infectious men having sex with susceptible men
beta_ff = 0.18; %Transmission probability from infectious women having sex with susceptible women
beta_mf = 0.01; %Transmission probability from infectious men having sex with susceptible women
beta_fm = 0.18; %Transmission probability from infectious women having sex with susceptible men
%alpha_1 = 0.01; %Modification parameters in reducing transmission
alpha_2 = 0.1; %Modification parameters in reducing transmission
%alpha_3 = 1.5; %Modification parameters in reducing transmission
I_f = 27; %Population of infectious women
I_m = 28.22; %Population of infectious men
% plot
levels = (0:0.2:1.2);
[alpha_1, alpha_3] = meshgrid(0:0.005:0.03, 1:0.05:2);
R_0 = (alpha_3 .* beta_ff .* tau_m + beta_mm .* tau_f)./(2 .* tau_f .* tau_m) + sqrt(4 .* alpha_1 .* alpha_2 .* beta_fm .* beta_mf .* tau_f .* tau_m + alpha_3.^2 .* beta_ff.^2 .* tau_m.^2 - 2 .* alpha_3 .* beta_ff .* beta_mm .* tau_f .* tau_m + beta_mm.^2 .* tau_f.^2) ./ (2 .* tau_f .* tau_m);
[c,h] = contourf(alpha_3,alpha_1,R_0,levels);
clabel(c,h)
h.LineWidth = 2; % contour line width (up to you)
xlabel('\alpha_3');
ylabel('\alpha_1');
colormap(jet(numel(levels)-1));
colorbar('vert');
figure()
surf(alpha_3,alpha_1,R_0);
view(3)
0 commentaires
Voir également
Catégories
En savoir plus sur Line Plots 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!