calculate mean value for each hour of the day from a time series
조회 수: 3 (최근 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!