例1:y'=ry(1-y/K)

          y(0)=2

对应的R代码为:

library(deSolve)
#parameters and initial values
r<-1
K<-10
yini<-2
#the function
derivs<-function(t,y,parms){
                 return(list(r*y*(1-y/K)))
        }
#the independent variables
times<-seq(from=0,to=20,by=0.2)
#to calculate y values
out<-ode(y=yini,times=times,func=derivs,parms=NULL)
#the results
out

参考文献:

Karline S, Thomas P, Setzer R W. Solving Differential Equations in R[M]. Springer Publishing Company, Incorporated, 2012.

内容来源于网络如有侵权请私信删除
你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!