MATLAB: From a=[1 2 3 4] to b=[1 1 2 2 3 3 4 4]

repelem

code: from a=[1 2 3 4] to b=[1 1 2 2 3 3 4 4]

Best Answer

b = repelem(a,2)