Azzera filtri
Azzera filtri

repeating elements of vector by the no. of times equal to elements in another vector

2 visualizzazioni (ultimi 30 giorni)
i have a vector v. i have another vector of same length, r. i want to take first element of v, v(1), repeat it r(1) times, store it in a big vector W. then i want to take second element of v, v(2), repeat it r(2) times, and append W with it. and so on until all elements in v are finished.
i want this:
W= [ [v(1) repeated r(1) times] [v(2) repeated r(2) times] .......[v(n) repeated r(n) times] ] where n is the length of r and v. How can i do this?

Risposta accettata

Birdman
Birdman il 3 Apr 2018
repelem(v,r)

Più risposte (0)

Categorie

Scopri di più su Multidimensional Arrays in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by