MATLAB: Extending an order in a vector

MATLABvector

I have a vector that provides me with a strict order of n number. If n is 5, for example, I type
y=randperm(5)
and I get something like
1 3 5 4 2
I want to scale this order by a factor of x. If x=3, I would like to get
1 2 3 7 8 9 13 14 15 10 11 12 4 5 6
Is there an easy way to do this that I am missing? I know that
reshape(repmat(y,x=3,1),1,[])
creates
1 1 1 3 3 3 5 5 5 4 4 4 2 2 2
and then I can add 1 to 3 using a loop, but surely there is something faster that I am missing.

Best Answer

One way:
>> result = cell2mat(arrayfun(@(y)x*y-x+1:x*y,y,'uni',false))
result =
1 2 3 7 8 9 13 14 15 10 11 12 4 5 6