代码:library(deSolve)
m<-c(0,1,1,1,0,1,1,1,0)
A<-matrix(m, byrow=T, nrow=3)
A
n<-ncol(A)
n
Lorenz<-function(t,state,parameters){
with(as.list(c(state,parameters)),{
for (i in 1:n) {
for (j in 1:n) {
A1<-R*A[i][j]*X[i]*X[j]
}
dX[i]<-F-B*X[i]-apply(A1,1,sum)
}
})
list(c(dX))
}
state=c(X=1,Y=1,Z=1)
#进行两面映射图像的设置
parameters<-c(F=-8/3,B=-100,R=0.5)
times<-seq(0,10,by=0.01)
out <- ode(y = state, times = times, func = Lorenz, parms = parameters)
out
运行出现的问题
Error in apply(A1, 1, sum) : dim(X) must have a positive length