MATLAB: Scale Matrix Dimensions by Factor

arrayMATLABmatrixmatrix manipulationscale

I have a matrix that needs to be scaled in the horizontal, copying each row.
Ex:
[1 2 3]
[4 5 6]
Scale Columns only by Factor 3
[1 1 1 2 2 2 3 3 3]
[4 4 4 5 5 5 6 6 6]
How can I write a simple loop to perform this. Thanks!

Best Answer

>> repelem([1 2 3],3)
ans =
1 1 1 2 2 2 3 3 3
>>