Can I create a dates?

2 次查看(过去 30 天)
Edoardo
Edoardo 2012-11-24
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

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by