Let's say I have a one-dimensional array:
a = [1, 2, 3];
Is there a built-in Matlab function that takes an array and an integer n
and replicates each
element of the array n times?
For example calling replicate(a, 3)
should return [1,1,1,2,2,2,3,3,3]
.
Note that this is not at all the same as repmat
. I can certainly implement replicate
by doing repmat
on each element and concatenating the result, but I am wondering if there is a built in function that is more efficient.