I'm trying to decompose a 9x9 matrix into 9 3x3 matrices. I've already used the command reshape, but the matrices it returns are the ones as transforming the columns of the 9x9 matrix to 3x3 matrices, but that isn't what I need. This is 9x9 the matrix M
0 0 0 0 0 0 0 7 6
0 2 0 9 0 0 0 0 0
0 3 8 0 5 4 1 0 0
9 0 0 5 0 0 0 3 0
0 0 0 0 1 8 0 6 7
4 0 0 0 0 0 2 0 0
0 1 0 8 0 0 0 5 0
0 0 0 0 0 7 0 0 0
6 0 2 0 3 0 8 9 4
And I need it in form
0 0 0 0 0 0 0 7 6
0 2 0 9 0 0 0 0 0
0 3 8 0 5 4 1 0 0 etc...
This code generates the matrices exactly as I need them, but only saving the last one:
for i=[1 4 7]
for j=[1 4 7]
v(:,:)=M([i:i+2],[j:j+2])
end
end