MATLAB: Repeating elements of vector by the no. of times equal to elements in another vector

repmat

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?

Best Answer

repelem(v,r)