MATLAB: Can I create a dates

countdatesMATLAB

Hi;
I would like create a matrix with only one colomn.
In my matrix I want to put the dates in this format 19890101 – 19890102 etc.
Each date must be written to seven times
(19890101,19890101,19890101,19890101,19890101,19890101,19890102,19890102,19890102,19890102,19890102,19890102,19890102,19890102 etc..). All this for 30 years.
I have to take account of the months with 28, 30 and 31 days and leap years.
Can you help me
Thanks

Best Answer

serdates = datenum('19890101', 'YYYYMMDD') : datenum('20191231');
vecdates = datevec(serdates);
decdates = vecdates(:,1) * 10000 + vecdates(:,2)*100 + vecdates(:,3);
datecol = reshape( repmat(decdates(:) .', 7, 1), [], 1);