我知道这是一个简单的修复,但有人可以看看它:
a12= 0
a21= 0
K1= 1000
K2= 600
r1= 0.2
r2= 0.1
N1= ((K1 - a12*K2)/(1 - a12*a21))
N2= ((K2 - a21*K1)/(1 - a21*a12))
for(t in 1:80){
N1[t+1]= N1(t) + r1*N1(t)*(K1 - N1 - a12*N2)/K1
N2[t+1]= N2(t) + r2*N2(t)*(K2 - N2 - a21*N1)/K2
}
## Error: could not find function "N1"
更正的代码:
N1= rep(0,80)
N2= rep(0,80)
a12= 0
a21= 0
K1= 1000
K2= 600
r1= 0.2
r2= 0.1
N1[1]= ((K1 - a12*K2)/(1 - a12*a21))
N2[1]= ((K2 - a21*K1)/(1 - a21*a12))
for(t in 1:80){
N1[t+1]= N1[t] + r1*N1[t]*(K1 - N1[t] - a12*N2[t])/K1
N2[t+1]= N2[t] + r2*N2[t]*(K2 - N2[t] - a21*N1[t])/K2
}
plot(1:81, N1, type="l", lwd=3, xlab="Time")
lines(1:81, N2, lwd=3, col='red')
当我运行我更改 a12 和 a21 值的地块时,它们看起来就像我预期的那样,因为它们模拟了两个物种之间的竞争力。
我正在运行的三个模型:
no competition- a12=0 a21=0
stable coexistence- a12=0.25 a21=0.1
competitive exclusion- a12=0.25 a21=0.75