Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

reshape2D.m 557 B

123456789101112131415161718192021
  1. function f = reshape2D(m,dim)
  2. % function f = reshape2D(m,dim)
  3. %
  4. % <m> is a matrix
  5. % <dim> is a dimension of <m>
  6. %
  7. % shift dimension <dim> to the beginning,
  8. % then reshape to be a 2D matrix.
  9. % see also reshape2D_undo.m.
  10. %
  11. % example:
  12. % a = randn(3,4,5);
  13. % b = reshape2D(a,2);
  14. % isequal(size(b),[4 15])
  15. % what is the new permutation order? (be careful that <dim> might be larger than number of dimensions of <m>!)
  16. dimorder = [dim setdiff(1:max(ndims(m),dim),dim)];
  17. % permute and then squish into a 2D matrix
  18. f = reshape(permute(m,dimorder),size(m,dim),[]);