【发布时间】:2018-02-22 22:50:02
【问题描述】:
我试图在我的代码中通过我的 tspan 运行一个 forloop,以便某些参数随时间变化(特别是每个季节)。
这是我目前在该部分代码中的内容:
Tmax = 7300; %years times days
tspan = 0:1:Tmax; %tspan from day 1 to Tmax
Mu = [500 1500 500 0]; %vectors for each function of t, with values per season starting with spring
Day = zeros(Tmax,1);
count = 1;
for t = 1:Tmax
S = floor(mod(t,365)/(366/4))+1; %Denotes the season
Day(t) = Mu(S);
end
但是,我不断收到错误消息“未定义的函数或变量 S”。有什么见解吗?
【问题讨论】:
-
你确定这段代码重现了你的错误吗?
-
尝试在出现错误的地方设置一个断点,然后查看 t(和 S)的值。