我的循环无法从第三个else if
开始工作。
我希望如果该陈述属实,那个位置的Cumu_excess_se2
在该位置等于Excess_se
并从那里到Cumu_excess_se(t) =Cumu_excess(t-1) + Excess_se(t)
我的载体是:
Q
每小时可提供太阳能电力Excess_se
是每小时存储的超额Cumu_excess_se2
是多余循环:
for (j in 1:length(Cumu_excess_se)) {
Cumu_excess_se[j] = sum(Excess_se[1:j])
se.to.h <- vector("numeric", length(Excess_se))
for (t in 1:length(se.to.h)) {
if (Q[t] > maxse) {
se.to.h[t] = maxse
} else if ((Q[t] < maxse) & (Cumu_excess_se2[t] == 0)) {
se.to.h[t] = Q[t]
} else if ((Q[t] < maxse) & (Cumu_excess_se2[t] >= maxse)) {
(se.to.h[t] = maxse) & (Cumu_excess_se2[t] = Cumu_excess_se2[t - 1] - (maxse - Q[t]))
} else if ((Q[t] < maxse) & (Cumu_excess_se2[t] < maxse) & (Cumu_excess_se2[t] > 0)) {
(se.to.h[t] = Cumu_excess_se2[t]) & (Cumu_excess_se2[t + 1] = Excess_se[t + 1])
}
}
}