Effacer les filtres
Effacer les filtres

Can I create a dates?

1 vue (au cours des 30 derniers jours)
Edoardo
Edoardo le 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

Réponse acceptée

Walter Roberson
Walter Roberson le 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);

Plus de réponses (0)

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by