MATLAB: Creating dates tables with loop

datesloopsMATLABtable

I am trying to build a matrix that contains dates separated by a time step. It woks well for the first two lines, but then it is missing a second. This is the answer i get
['16.04.2014 00:00:00'
'16.04.2014 01:00:00'
'16.04.2014 01:59:59'
'16.04.2014 02:59:59'
'16.04.2014 03:59:59'
'16.04.2014 04:59:59'
...]
It is happening only when I defined the time step as 1. Does anyone knos how can I make it work correctly?
dates(1,1)=datenum('16.04.2014 00:00:00', 'dd.mm.yyyy HH:MM:SS');
df=datenum('07.06.2016 23:59:59', 'dd.mm.yyyy HH:MM:SS'); %Final date
ddate=1; %specify time step in hours
for i=2:(df-dates(1))*24/ddate+1
dates(i,1)=dates(i-1,1)+(ddate/24);
end
%dates(end,2)=df;
dates=datetime(dates,'ConvertFrom','datenum', 'Format', 'dd.MM.yyyy HH:mm:ss');

Best Answer

dates = (datetime(2014,4,16,0,0,0):hours(1):datetime(2016,6,8,0,0,0))';