Year in column 1 and month in column 2
1 view (last 30 days)
Show older comments
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 Comments
Answers (2)
Stephan
on 18 Jan 2019
col1 = repelem(1901:2017,12)';
col2 = repmat(1:12,1,numel(col1)/12)';
result = [col1 col2]
0 Comments
madhan ravi
on 18 Jan 2019
Perhaps?
t=datetime(2017,01,01):calmonths(1):datetime(2017,12,31);
[year,month,~]=ymd(t);
Result=[year(:) month(:)]
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!