I want to repeat each element of 3x3 matrix to make it 9x9. There is a direct function repelem in Matlab2015, but i am using older version.
How to perform this task manually?
I want to repeat each element of 3x3 matrix to make it 9x9. There is a direct function repelem in Matlab2015, but i am using older version.
How to perform this task manually?
You can use the kron(A,B) function. It was introduced before R2006a so you should have it in R2014. This function calculates the Kronecker Tensor Product. It multiplies each element of matrix A with the full matrix B and thus creating a bigger matrix. For example,
>> A = magic(3)
A =
8 1 6
3 5 7
4 9 2
>> B = ones(3)
B =
1 1 1
1 1 1
1 1 1
>> C = kron(A,B)
C =
8 8 8 1 1 1 6 6 6
8 8 8 1 1 1 6 6 6
8 8 8 1 1 1 6 6 6
3 3 3 5 5 5 7 7 7
3 3 3 5 5 5 7 7 7
3 3 3 5 5 5 7 7 7
4 4 4 9 9 9 2 2 2
4 4 4 9 9 9 2 2 2
4 4 4 9 9 9 2 2 2