Azzera filtri
Azzera filtri

The code is plotting $R_0$ against two parameters

2 visualizzazioni (ultimi 30 giorni)
Codex
Codex il 30 Ott 2023
Modificato: Dyuman Joshi il 24 Nov 2023
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);
Error using contourf
Z must be at least a 2x2 matrix.
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 Commenti
Codex
Codex il 30 Ott 2023
R_0 represent basic reproduction number.
alpha_1 = 0.01; %Modification parameters in reducing transmission
alpha_3 = 1.5; %Modification parameters in reducing transmission
This is to investigate the relation of the basic reproduction number (R_0) against the alpha_1 and alpha_3. And it can be R_0 against beta_mm
Dyuman Joshi
Dyuman Joshi il 24 Nov 2023
Modificato: Dyuman Joshi il 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.

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 30 Ott 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);
Name Size Bytes Class Attributes I_f 1x1 8 double I_m 1x1 8 double R_0 21x7 1176 double alpha_1 21x7 1176 double alpha_2 1x1 8 double alpha_3 21x7 1176 double alpha_f 1x1 8 double alpha_m 1x1 8 double beta_ff 1x1 8 double beta_fm 1x1 8 double beta_mf 1x1 8 double beta_mm 1x1 8 double cmdout 1x33 66 char levels 1x7 56 double tau_f 1x1 8 double tau_m 1x1 8 double
[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)

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by