MATLAB: Creating a timeseries using number of rows

timestamps

I want to create a timeseries in the format 'dd-mm-yyy hh:mm' and I want the granularity of data to be hourly.
For example, if my first entry is '01-01-2015 00.00', I want the second entry to be '01-01-2015 01:00'
I tried doing the following:
ts1.TimeInfo.StartDate = '04-Jan-2015 00:00'; % Set start date.
ts1.TimeInfo.Format = 'dd-mm-yyyy hh:mm';
ts1.Time = ts1.Time – ts1.Time(1);
but I am getting data by the minute. ie:
04-Jan-2015 00:01
04-Jan-2015 00:02
How to I solve this problem? ANy help would be appreciated.

Best Answer

Try something like this
t1 = datetime('04-Jan-2015 00:00', 'Format', 'dd-MM-yyyy HH:mm');
t2 = datetime('07-Jan-2015 00:00', 'Format', 'dd-MM-yyyy HH:mm');
t = t1:hours(1):t2;