我正在写for循环来平均每小时进行10年的小时测量。测量日期记录为MATLAB日期。在MATLAB中按小时迭代循环
我想通过使用0.0417进行迭代,因为它是1AM 00/00/00的datenum,但是每次迭代时都会在几秒钟内添加错误。
任何人都可以推荐一个更好的方法来让我按小时迭代吗?
date = a(:,1);
load = a(:,7);
%loop for each hour of the year
for i=0:0.0417:366
%set condition
%condition removes year from current date
c = date(:)-datenum(year(date(:)),0,0)==i;
%evaluate condition on load vector and find mean
X(i,2)=mean(load(c==1));
end
这么简单很明显,非常感谢。 – kekni