MATLAB: How to calculate the hourly data points

loop

Hi everyone,
May someone help me here ..
I have a long data in time-date formate i.e. six columns YYYY MM DD HH MM SS. Each time values indicate an observation. I want to calcualte the number of observations per hours. It is importanmt to mentioned that frequency of observations is uneven i.e. 10 or 100 obsservation per hour and no observation for a couple of days. So the output must account the missing time as well wehre there is no observation recorded.
Thank You!

Best Answer

Try retime():
T = readtable('data.xlsx');
t = datetime(T.YYYY, T.MM, T.DD, T.HH, T.MM_1, T.SS);
TT = timetable(t, ones(size(t)));
newTT = retime(tt, 'hourly', 'sum');
newT = table(newTT.t, newTT.Var1, 'VariableNames', {'Time', 'count'});