MATLAB: Calculating hourly means of a matrix

time series

I have a dataset in the following format:
dd = datenum('2009-04-17 02:00');
ddend = datenum('2009-11-24 12:27');
Day = dd:(1./24./60):ddend;
time = datevec(Day);
data = rand(length(time),12);
Where time refers to the time (in minutely intervals) and data refers to a matrix of data points. I would like to find the best possible way of calculating the hourly means of each column of the matrix (i.e. mean of every 24 rows in each individual column). How would I achieve this, by taking into consideration the time variable?

Best Answer

limit = floor(length(time) / 60) * 60;
data_hour = reshape(data(1:limit), 60, []);
data_mean = mean(data_hour, 1);
Related Question