generating monthly date series
古いコメントを表示
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 件)
Andrei Bobrov
2011 年 6 月 16 日
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 ]]));
カテゴリ
ヘルプ センター および File Exchange で Time Series Objects についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!