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??

回答(2 个)

Stephan
Stephan 2019-1-18
col1 = repelem(1901:2017,12)';
col2 = repmat(1:12,1,numel(col1)/12)';
result = [col1 col2]

madhan ravi
madhan ravi 2019-1-18
Perhaps?
t=datetime(2017,01,01):calmonths(1):datetime(2017,12,31);
[year,month,~]=ymd(t);
Result=[year(:) month(:)]

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by