calculate mean value for each hour of the day from a time series
4 ビュー (過去 30 日間)
古いコメントを表示
I would like to calculate the hourly mean values for the following time series:
DateTime = datestr(datenum('2011-01-01 00:00','yyyy-mm-dd HH:MM'):1/24:...
datenum('2011-12-31 23:00','yyyy-mm-dd HH:MM'),...
'yyyy-mm-dd HH:MM');
DOY = datenum(cellstr(DateTime)) - datenum(2011,0,0);
data = 1 + (30-1).*rand(length(DOY),1);
DOY defines the decimal day of year and data represents the example data set. From this, I would to generate an array of 24 values, where each value corresponds to the mean value for that particular hour of the day. so the first value should be the mean of the first value in 'data' and every 25 rows following each (where each 24 rows corresponds to a different day)
0 件のコメント
回答 (1 件)
Miro
2012 年 7 月 19 日
for example like this:
t = yourstartdate;
dt = 1/24;
while t < yourenddate
datatmp = mean(data(Tarray <t+dt & Tarray >t));
Dataout = [Dataout;datatmp]
t=t+dt;
end
so what you need to have is the Tarray, that contains the datenums of all the data (so it has the same length as data).
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Dates and Time についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!