我正在尝试绘制带有随机参数的循环的多次迭代的图,但是我的图一直在将一条线从最大值追溯到0。
A<-2.012
V<-34
J<- -278.01
Sos<-0.0172
t <- 5
D <- NA
mad <- 1696
dib <- 1335
egg<-((2029.05*mad)+(4271.76*dib))
total <- (dib+mad)
Salmon <- rbind(Salmon,c(t,mad,dib,egg,D,total))
for(i in 1:10){
for(t in 6:34){
D <- sample(133:150,size=1,replace=TRUE)
egg <- Salmon[t-1,4]
Smolt3<-egg*Sos
Smoltmer<-((A*(D+V)+J)/100)*Smolt3
mad <- Salmon[t-1,2]
dib <- ((Salmon[t-1,3])-(Salmon[t-1,2]))
if(dib<0){dib <- 0}else{dib <- dib}
egg<-((2029.05*mad)+(4271.76*dib))
dib<-(Smoltmer*0.003569)
mad<-((Smoltmer*0.57)*exp(-1.6543))
total <- (dib+mad)
Salmon <- rbind(Salmon,c(t,mad,dib,egg,D,total))
}
plot(Salmon[,6]~Salmon[,1], ylim=c(0,8e+05), type="l", lty=1, lwd=2, xlab="Temps (an)",
ylab="Abondance (n)")
par(new=TRUE)
}