我已经制作了一个函数,可以从给定月份和年份的特定时间从数据集中提取所有温度。
看起来像: exctractperiod(data, year, month, time)
如前所述,这将一次提取特定月份的所有温度,例如 1400。
我现在想找到某个月份的最低温度,比如多年的一月。例如,如果我查看 1997 年到 2006 年之间的 1 月。现在我想要 1997 年到 2006 年之间 1 月的最低注册温度。
到目前为止我的进展是下面的代码:
function [algo] = getMiniserieone(data, startYear, endYear, time)
v = zeros(12,2);
for month = 1:12
for year = startYear:1:endYear
p = extractperiodtwo(data, year, month, time);
q = min(p);
v(month,1) = v(month,1) + q;
v(month,2) = v(month,2) + 1;
algo = v(12,2);
end
end
end
但是,我确实收到了错误消息:
Unable to perform assignment because the size of the left side is
1-by-1 and the size of the right
side is 0-by-1.
在命令窗口调用函数时:
>> getMiniserieone(data, 1996, 2006, 1400)
Error in getMiniserieone (line 12)
v(month,1) = v(month,1) + q;
但我一直无法解决这个问题。
我对上述程序的意图是让我们假设 1996 年至 2006 年期间的特定时间提取 1 月至 12 月之间所有月份的最低温度。这意味着在 1996 年至 2006 年 1 月之间的某个时间,比如 1300 年,我想要当时那个月的最低温度。然后将其存储在我的向量v第 1 列中,第 2 列将表示月份。
我的问题是如何解决这个问题,我不确定错误消息是什么意思?这是否可能意味着 q 不是单个元素值?
我希望所提供的信息足以理解问题,如果不能随意询问。
根据要求,代码extractPeriod()
function [mdata] = extractperiodtwo(data, year, month, time)
x = year*100 +month;
k = find( floor(TEMPUF(:,1)/100) == x & (data(:,2)==time));
mdata = data(k,3);
end