generating monthly date series
Mostrar comentarios más antiguos
Anyone has a way of generating a monthly series (say 1Feb2011 to 1Nov2015) without having to use a loop?
One could imagine a function like linspace:
dateseries(startdate,enddate,frequency)
e.g.
t = dateseries('1Feb2011','1Nov2015','monthly')
It's fairly easy to go via a datevec, but I think that there is a need for such a functionality.
The function should return a vector of datenums.
Kind regards, A. Damslora
1 comentario
André Damslora
el 16 de Jun. de 2011
Respuestas (1)
Andrei Bobrov
el 16 de Jun. de 2011
use Financial Toolbox
doc datemnth
doc months
COD:
dated = {'01-Feb-2011','01-Nov-2015'};
t = datemnth(dated{1}, (0: months(dated{:}))')
more variant without Financial Toolbox
v = datevec({'01-Feb-2011','01-Nov-2015'});
out = datenum(cumsum([v(1,1:3);ones(diff(v(:,1:3))*[12 1 0 ]',1)*[0 1 0 ]]));
1 comentario
André Damslora
el 16 de Jun. de 2011
Categorías
Más información sobre Time Series Objects en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!