calculate mean value for each hour of the day from a time series
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Miro
on 19 Jul 2012
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 Comments
See Also
Categories
Find more on Calendar in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!