matlab 根据两个参数绘制基本再现数

wko9yo5t  于 2022-11-30  发布在  Matlab
关注(0)|答案(2)|浏览(214)

我试图从论文中复制下面的图https://pubmed.ncbi.nlm.nih.gov/32834653/

下面给出了参数值和基本再生数的公式。

beta_s = 0.274
alpha_a = 0.4775
alpha_u = 0.695
mu = 0.062
gamma_a = 0.29
q_i = 0.078
1/eta_i = 0.009
1/eta_u = 0.05

R_0 = (beta_s*alpha_a)/(gamma_a+mu) + (beta_s*alpha_u*gamma_a*(1-q_i))/((gamma_a+mu) 
(eta_u+mu))

如果有人能帮我用R或MATLAB绘制图表,我将非常感谢。

vyu0f0g1

vyu0f0g11#

添加到@AlanCameron的回答中添加水平面:

## previous code
perspbox(beta, gamma, z = R, theta = -50, ticktype = "detailed",
         col.grid = "gray85", bty = "u",
         xlab = "\u03b2\u209b", ylab = "\u03b3\u2090")

pp <- persp3D(beta, gamma, z = R, theta = -50, add = TRUE)

水平加面功能:

plane3D <- function(z, 
              col = adjustcolor("blue", alpha.f = 0.2),
              border = NA,
              xlim = c(0,0.4), ylim = c(0, 0.4)) {
   dd <- expand.grid(x=xlim, y = ylim, z= z)
   rr <- with(dd, trans3D(x,y,z,pp))
   perm <- c(1,3,4,2)
   polygon(rr$x[perm], rr$y[perm], col = col, border = border)
}

添加平面:

plane3D(1)
plane3D(2, col = adjustcolor("red", alpha.f = 0.2))

使用rgl包也可以很容易地完成这些基本操作,它还允许动态旋转并正确处理遮挡:

library(rgl)
persp3d(beta, gamma, R, theta = -50, col = "gray")
## horizontal plane at z = Z →
##    0*x + 0*y + 1*z - Z = 0
##  a = 0, b = 0, c = 1, d = -Z 
planes3d(0, 0, 1, -1, col = "red")
planes3d(0, 0, 1, -2, col = "blue")

装饰(表面的颜色渐变等)有点难。

vwhgwdsa

vwhgwdsa2#

在R中,可以使用plot3D库:

library(plot3D)

R_0 <- function(beta_s, gamma_a, alpha_a = 0.4775, alpha_u = 0.695,
                mu = 0.062, q_i = 0.078, eta_i = 0.009, eta_u = 0.05) {
  
  A <- beta_s * alpha_a / (gamma_a + mu) 
  B <- beta_s * alpha_u * gamma_a * (1 - q_i) / ((gamma_a + mu) * (eta_u + mu))
  A + B
}

beta <- gamma <- seq(0, 0.4, length.out = 100)

R <- outer(beta, gamma, R_0)

perspbox(beta, gamma, z = R, theta = -50, ticktype = "detailed",
         col.grid = "gray85", bty = "u",
         xlab = "\u03b2\u209b", ylab = "\u03b3\u2090")

persp3D(beta, gamma, z = R, theta = -50, add = TRUE)

相关问题