Suppose the input matrix is:
a=[1,2,3; 4,5,6; 7,8,9];
the expect output matrix would be:
[1 1 1 2 2 2 3 3 3
4 4 4 5 5 5 6 6 6
7 7 7 8 8 8 9 9 9]
Is there a neat matlab function to do this? Many thanks for your time and attention.