MATLAB: Array manipulation such as [ 1 2 5 7 3 …. ] –> [ 1 1 1 … 2 2 2 … 5 5 5 … 7 7 7 … 3 3 3 … …. ].

array manipulation

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.

Best Answer

repelem(A, 3)