sorry 30 years data, 12*30=360
how to select particular rows of a column vector repeatedly?
1 回表示 (過去 30 日間)
古いコメントを表示
I have a column vector containing 360 rows(monthly data, 12*10 years=360) and one column. i want to select monthly data of march, april and may of every year. i.e., I need to select 3rd,4th,5th rows for every 12 rows.like that for the 10 years.
採用された回答
madhan ravi
2019 年 8 月 8 日
編集済み: madhan ravi
2019 年 8 月 8 日
I’m not exactly sure what you mean, perhaps:
vector(repmat([3,4,5],1,10))
edit:
vector(sort([3:12:360,4:12:360,5:12:360]))
2 件のコメント
その他の回答 (1 件)
Walter Roberson
2019 年 8 月 8 日
mask = ismember(mod( (1:12*10) - 1, 12) + 1, [3 4 5]);
YourVector(mask)
The form mod(x-1,N)+1 is a common formula to transform mod(x, N) which woud return 0 1 2 3 ... N-1, into a function that returns 1 2 3 ... N
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Frequently-used Algorithms についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!