Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %your parameters
- n=2
- j=4
- %some example matrix
- M=magic(n*j);
- %create the input for blkdiag, j matrices of size n
- h=repmat({true(n)},j,1)
- %use blkdiag to select the elements
- M(logical(blkdiag(h{:})))
- n=2;
- j=4;
- %some example matrix
- M=magic(n*j);
- linIndices = (0:n*((n*j)+1):n*((n*j)+1)*(j-1))+reshape((1:n)'+n*j*(0:n-1),[],1);
- newM = reshape(M(linIndices),n,n,[]);
Add Comment
Please, Sign In to add comment