MATLAB: Creating time date matrix

engineeringmathematics

I want to create an hourly date/time (366 x24) matrix starting from 2000-01-01 and ending 2000-12-31. It must start at midnight 00:00 and end at 23:00 for each day. I would also like each new day to begin in a new row. How do i do that?

Best Answer

One possible solution would be like this.
T = datetime(2000,1,1):hours(1):datetime(2000,1,1,23,0,0);
T = repmat(T,366,1);
T = T + days(repmat((0:365)',1,24));