given two dates (1/1/2012, 12/1/2012), how to have an array of months (1/1/2011,2/1/2011,...,12/1/2012)??
Mostra commenti meno recenti
given two dates (1/1/2012, 12/1/2012), how to have an array of months between the two dates[1/1/2011,2/1/2011,...,12/1/2012]??
Risposte (2)
Leah
il 27 Gen 2012
something like this maybe
dv=datenum('1/1/2012'): datenum('12/1/2012');
dv=datevec(dv);
dv=datenum(dv(dv(:,3)==1,:)); %only take dates where day==1
datestr(ans)
3 Commenti
Sean de Wolski
il 27 Gen 2012
Nice! I think you meant datestr(dv) though.
This could be easily modifed to do weird dates to March 3rd to July 3rd etc
Nan Shen
il 27 Gen 2012
Leah
il 27 Gen 2012
Glad to help, I do lots of time series analysis.
Walter Roberson
il 27 Gen 2012
nummon = 12; %stats for 12 conseq months
monstarts = datenum( [2012*ones(nummon,1), (1:nummon).',
ones(nummon,1)]);
The above would be in serial date format. You can use datestr() to convert to printable dates.
Categorie
Scopri di più su Time Series Objects in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!