Effacer les filtres
Effacer les filtres

Produce a Date vector starting with a desired date

1 vue (au cours des 30 derniers jours)
Christoph Meier
Christoph Meier le 11 Août 2015
Commenté : Star Strider le 11 Août 2015
Dear all, I am trying to produce a date vector, which includes year and month I would like to start With July 1926, and end with December 2014. Optimally, the format should be YYYYMM.
Thank you very much in advance!
Chris

Réponse acceptée

Star Strider
Star Strider le 11 Août 2015
This seems to work:
date1 = datenum('192607','yyyymm');
date2 = datenum('201412','yyyymm');
datev = date1:(365.25/13):date2;
result = unique(datestr(datev, 'yyyymm'),'rows');
sample = result(1:24,:) % Sample Output
  2 commentaires
Christoph Meier
Christoph Meier le 11 Août 2015
thank you very much, Star Strider. I appreciate your help!
Star Strider
Star Strider le 11 Août 2015
My pleasure!

Connectez-vous pour commenter.

Plus de réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 11 Août 2015
d1='192607'
d2='201412'
dd1=datenum(d1,'yyyymm')
dd2=datenum(d2,'yyyymm')
out=datestr(dd1:dd2,'yyyymm')
  1 commentaire
Christoph Meier
Christoph Meier le 11 Août 2015
Dear Azzi, thank you very much! I followed your instructions, and get the following output:
192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192607 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192608 192609 192609 192609 192609 192609 192609 192609 192609
The problem is that '192607' is repeating 30 times, for each day of the months, but I am looking for the following format: 192607 192608 192609 ...
Thank you very much!

Connectez-vous pour commenter.

Catégories

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

Community Treasure Hunt

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

Start Hunting!

Translated by