Year in column 1 and month in column 2
1 次查看(过去 30 天)
显示 更早的评论
I want to create a time series with year in column 1 (1901-2017) and month in column 2 (1-12 repeated with changing year)
1901 1
1901 2
1901 3
.
.
.
.
2017 12
How can I do so??
0 个评论
回答(2 个)
Stephan
2019-1-18
col1 = repelem(1901:2017,12)';
col2 = repmat(1:12,1,numel(col1)/12)';
result = [col1 col2]
0 个评论
madhan ravi
2019-1-18
Perhaps?
t=datetime(2017,01,01):calmonths(1):datetime(2017,12,31);
[year,month,~]=ymd(t);
Result=[year(:) month(:)]
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!