how to select particular rows of a column vector repeatedly?

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

madhan ravi
madhan ravi il 8 Ago 2019
Modificato: madhan ravi il 8 Ago 2019
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 Commenti
ANUSHA SOMISETTY
ANUSHA SOMISETTY il 8 Ago 2019
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

Accedi per commentare.

Più risposte (1)

Walter Roberson
Walter Roberson il 8 Ago 2019
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

Categorie

Scopri di più su Frequently-used Algorithms in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by