how to select particular rows of a column vector repeatedly?

1 回表示 (過去 30 日間)
ANUSHA SOMISETTY
ANUSHA SOMISETTY 2019 年 8 月 8 日
コメント済み: madhan ravi 2019 年 8 月 8 日
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
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 件のコメント
ANUSHA SOMISETTY
ANUSHA SOMISETTY 2019 年 8 月 8 日
thank you. i want to select the march, april and may data for the 30 years. 30 years monthly flow data is in a single column with (30years*12months=360) 360 rows.
data is like
1.3 for jan/2001
4.6 for feb/2001
4 for march/2001
.
.
3.2 for jan 2002
.
.
.
5.6 for december/2030
so 0ut of 360 rows, i need to select 3rd(march2001),4th(april2001),5th(may2001),15th(march2002), 16th, 17th, 27th 28th, 29th,39th,40th,41st....351st, 352nd,353rd (may2030)rows
madhan ravi
madhan ravi 2019 年 8 月 8 日
The edit should be giving what you want.

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
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

カテゴリ

Help Center および File ExchangeFrequently-used Algorithms についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by