Hi,
I have a 4D matrix S of size:S(2N+1,2N+1,M,M) where N and M are intergers. I was able to construct S(:,:,J,m) (using for loop for J=1:M and m=1:M) which are 2D (2N+1,2N+1) sub-matrices. I need to build a two dimensional big matrix Sbig of size: Sbig(M*(2N+1),M*(2N+1)) and find its transpose. I was only able to extract 2D matrices using squeeze(S(:,:,J,m)) but was not able to put them into big matrix Sbig(M*(2N+1),M*(2N+1)). I also used reshape another matrix "Ainv" of size (2N+1,M) into vector "C" using "reshape": C = reshape(T*Ainv, [M*(2*N+1) 1]), but it did not work for matrix since it orders all elements in column order.
I saw the pattern in Sbig matrix and wrote it in for loop:
for J=1:Mfor m=1:MSbig( ((J-1)*(2*N+1):J*(2*N+1)), ((m-1)*(2*N+1):m*(2*N+1)) ) = squeeze(S(:,:,J,m));endend
but again getting errors:
?????Subscript indices must eitherbe real positive integers orlogicals.
Is there way to write elements of Sbig(M*(2N+1),M*(2N+1)) matrix using a (2N+1,2N+1) submatrices squeeze(S(:,:,J,m))?
Best Answer