我正在寫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