Guest User

Untitled

a guest
Dec 17th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. %your parameters
  2. n=2
  3. j=4
  4. %some example matrix
  5. M=magic(n*j);
  6. %create the input for blkdiag, j matrices of size n
  7. h=repmat({true(n)},j,1)
  8. %use blkdiag to select the elements
  9. M(logical(blkdiag(h{:})))
  10.  
  11. n=2;
  12. j=4;
  13. %some example matrix
  14. M=magic(n*j);
  15. linIndices = (0:n*((n*j)+1):n*((n*j)+1)*(j-1))+reshape((1:n)'+n*j*(0:n-1),[],1);
  16. newM = reshape(M(linIndices),n,n,[]);
Add Comment
Please, Sign In to add comment