Hi all,
I would like to know how I can use the blkdiag function for the case of a 3D matrix. In specific, what I mean is the following:
Lets say I have the two following 3D matrices
A(:,:,1) = 1 1 1 1 1 1 1 1 1A(:,:,2) = 2 2 2 2 2 2 2 2 2 %================
B(:,:,1) = 3 3 3 3 3 3 3 3 3 B(:,:,2) = 4 4 4 4 4 4 4 4 4
And I would like to convert those to some matrix D such that blkdiag(A,B) would give the following:
D(:,:,1) = 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 0 0 0 3 3 3 0 0 0 3 3 3 0 0 0 3 3 3D(:,:,2) = 2 2 2 0 0 0 2 2 2 0 0 0 2 2 2 0 0 0 0 0 0 4 4 4 0 0 0 4 4 4 0 0 0 4 4 4
However I find that when trying to use the blkdiag function in such context I get an error. Any other thoughts for a work around?
Thanks for your help in advance.
Best Answer