求解R中的微分方程-deSolve

问题描述 投票:1回答:1

我的方程式如下;

dN/dt = N(t)G(t)

G(t)由以下公式给出:dG/dt = a * G如何使用deSolve包中的ode函数在R中解决此问题?

r ode differential-equations
1个回答
0
投票

如dario所述,该问题缺少一些细节。不过,让我们尝试一个答案。如果我们假设a < 0,则该模型看起来像Gompertz增长的颂歌公式:

dN/dt = N * G
dG/dt = a * G

然后可以解决为:

library(deSolve)

model <- function(t, y, p) {
  with(as.list(c(y, p)), {
    dN <-  N * G
    dG <-  a * G
    list(c(dN, dG))
  })
}

y      <- c(N = 1, G = 1)
parms  <- c(a = -0.1)
times  <- seq(0, 100)
out <- ode(y, times, model, parms)
plot(out)
© www.soinside.com 2019 - 2024. All rights reserved.