Can I create a dates?

4 views (last 30 days)
Edoardo
Edoardo on 24 Nov 2012
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

Accepted Answer

Walter Roberson
Walter Roberson on 24 Nov 2012
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);

More Answers (0)

Categories

Find more on Dates and Time in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!