MATLAB: Divide and expand matrix

MATLABmatrixmatrix manipulation

I have a 600×600 matrix with integer values in each cell. What I want to do is expand that matrix into a 6,000×6,000 matrix. However, since it is being expanded to 10x its size, I need to scale the integer in each cell accordingly. So if I have the value 10 in row 1 column 1 of the 600×600 matrix, I now need the value 1 in rows 1-10 columns1-10. Does anyone have any ideas how to do this?

Best Answer

Something like this you mean:
>> x=reshape(1:9,3,3) % starting sample input array
x =
1 4 7
2 5 8
3 6 9
>> N=2; % choose a multiplier size factor
>> xnew=cell2mat(arrayfun(@(x) repmat(x,N,N),x,'uniform',0))
xnew =
1 1 4 4 7 7
1 1 4 4 7 7
2 2 5 5 8 8
2 2 5 5 8 8
3 3 6 6 9 9
3 3 6 6 9 9
>>
ADDENDUM To divide down is as you surmise, just use N as divisor in the anonymous function--for the same x
>> cell2mat(arrayfun(@(x) repmat(x,N,N)/N,x,'uniform',0))
ans =
0.5000 0.5000 2.0000 2.0000 3.5000 3.5000
0.5000 0.5000 2.0000 2.0000 3.5000 3.5000
1.0000 1.0000 2.5000 2.5000 4.0000 4.0000
1.0000 1.0000 2.5000 2.5000 4.0000 4.0000
1.5000 1.5000 3.0000 3.0000 4.5000 4.5000
1.5000 1.5000 3.0000 3.0000 4.5000 4.5000
>>
ADDENDUM 2: Of course, if N is constant as above, it can come outside the anonymous function--
cell2mat(arrayfun(@(x) repmat(x,N,N),x,'uniform',0))/N
If it were a positional transform, the anonymous function could have a second argument of size(x) if need be or the dot division operator or automagic singleton expansion in later versions could come into play depending on just what a particular transformation looked like.