1- ( n x n , n x n ):
n = 3;
example = [1 2 3; 4 5 6; 7 8 9];
matrices = cat(3, example, 10*example, 100*example);
%// This is the list. Each third-dim slice is a matrix
[aux{1:n}] = deal(ones(n));
nz = ~blkdiag(aux{:}); %// template for filling result matrix
m = size(matrices,3); %// number of matrices in list
T = n^2; %// size of result matrix
N = n*(n-1); %// number of blocks
for ii = 0:m^N-1 %// number of results
ind = dec2base(ii,m,N)-'0'+1; %// indices of matrices to be used
result = zeros(T); %// initiallize to zeros
result(nz) = permute(reshape(matrices(:,:,ind),[n n n-1 n]),[1 3 2 4]);
%// fill in matrices given by ind
disp(result)
end
3- , n 3. , 729 . :
0 0 0 1 2 3 1 2 3
0 0 0 4 5 6 4 5 6
0 0 0 7 8 9 7 8 9
1 2 3 0 0 0 1 2 3
4 5 6 0 0 0 4 5 6
7 8 9 0 0 0 7 8 9
1 2 3 1 2 3 0 0 0
4 5 6 4 5 6 0 0 0
7 8 9 7 8 9 0 0 0
0 0 0 1 2 3 1 2 3
0 0 0 4 5 6 4 5 6
0 0 0 7 8 9 7 8 9
1 2 3 0 0 0 10 20 30
4 5 6 0 0 0 40 50 60
7 8 9 0 0 0 70 80 90
1 2 3 1 2 3 0 0 0
4 5 6 4 5 6 0 0 0
7 8 9 7 8 9 0 0 0
0 0 0 1 2 3 1 2 3
0 0 0 4 5 6 4 5 6
0 0 0 7 8 9 7 8 9
1 2 3 0 0 0 100 200 300
4 5 6 0 0 0 400 500 600
7 8 9 0 0 0 700 800 900
1 2 3 1 2 3 0 0 0
4 5 6 4 5 6 0 0 0
7 8 9 7 8 9 0 0 0
0 0 0 1 2 3 10 20 30
0 0 0 4 5 6 40 50 60
0 0 0 7 8 9 70 80 90
1 2 3 0 0 0 1 2 3
4 5 6 0 0 0 4 5 6
7 8 9 0 0 0 7 8 9
1 2 3 1 2 3 0 0 0
4 5 6 4 5 6 0 0 0
7 8 9 7 8 9 0 0 0
0 0 0 1 2 3 10 20 30
0 0 0 4 5 6 40 50 60
0 0 0 7 8 9 70 80 90
1 2 3 0 0 0 10 20 30
4 5 6 0 0 0 40 50 60
7 8 9 0 0 0 70 80 90
1 2 3 1 2 3 0 0 0
4 5 6 4 5 6 0 0 0
7 8 9 7 8 9 0 0 0
2- , ( (n + 1) x (n + 1) , n x n ):
. n=2.
n = 2;
matrices = cat(3, [1 2; 3 4], [10 20; 30 40], [100 200; 300 400]);
%// This is the list. Each third-dim slice is a matrix
[aux{1:n+1}] = deal(ones(n));
nz = ~blkdiag(aux{:}); %// template for filling result matrix
m = size(matrices,3); %// number of matrices in list
T = n*(n+1); %// size of result matrix
N = (n+1)*n; %// number of blocks
R = m^N; %// number of results
for ii = 0:R-1
ind = dec2base(ii,m,N)-'0'+1; %// indices of matrices to be used
result = zeros(T); %// initiallize to zeros
result(nz) = permute(reshape(matrices(:,:,ind),[n n n n+1]),[1 3 2 4]);
%// fill in matrices given by ind
disp(result)
end
:
0 0 1 2 1 2
0 0 3 4 3 4
1 2 0 0 1 2
3 4 0 0 3 4
1 2 1 2 0 0
3 4 3 4 0 0
0 0 1 2 1 2
0 0 3 4 3 4
1 2 0 0 10 20
3 4 0 0 30 40
1 2 1 2 0 0
3 4 3 4 0 0
0 0 1 2 1 2
0 0 3 4 3 4
1 2 0 0 100 200
3 4 0 0 300 400
1 2 1 2 0 0
3 4 3 4 0 0
0 0 1 2 10 20
0 0 3 4 30 40
1 2 0 0 1 2
3 4 0 0 3 4
1 2 1 2 0 0
3 4 3 4 0 0
0 0 1 2 10 20
0 0 3 4 30 40
1 2 0 0 10 20
3 4 0 0 30 40
1 2 1 2 0 0
3 4 3 4 0 0