Generating a long vector from two other vectors
Show older comments
I got stuck with a (may be) simple problem. Here are two vectors, like:
a = [20 13 24 ...];
b = [3 2 4 ...];
How can I create a new vector that contains 3 20s, 2 13s, 4 24s, and so on? (Not using any loop). The output will look like as shown in c:
c =
20 20 20 13 13 24 24 24 24 ...
Accepted Answer
More Answers (1)
Steven Lord
on 22 Jul 2015
v = repelem([20 13 24], [3 2 4])
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!