Clear Filters
Clear Filters

array manipulation such as [ 1 2 5 7 3 .... ] --> [ 1 1 1 ... 2 2 2 ... 5 5 5 ... 7 7 7 ... 3 3 3 ... .... ].

1 view (last 30 days)
Using
A = [ 1 2 5 7 3 .... ],
I would like to create
B = [ 1 1 1 ... 2 2 2 ... 5 5 5 ... 7 7 7 ... 3 3 3 ... .... ]
Can you please show me a way to do that? Thanks.

Accepted Answer

Jan
Jan on 17 Sep 2017
repelem(A, 3)

More Answers (1)

michio
michio on 17 Sep 2017
A = [ 1 2 5 7 3];
tmp = repmat(A,[3,1]);
B = tmp(:)';

Categories

Find more on Multidimensional Arrays 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!