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.

squish.m 523 B

1234567891011121314151617181920
  1. function f = squish(m,num)
  2. % function f = squish(m,num)
  3. %
  4. % <m> is a matrix
  5. % <num> is the positive number of initial dimensions to squish together
  6. %
  7. % return <m> squished.
  8. %
  9. % example:
  10. % isequal(squish([1 2; 3 4],2),[1 3 2 4]')
  11. % get the size of m
  12. msize = [size(m) ones(1,num-ndims(m))]; % add ones to end if necessary
  13. % calculate the new dimensions
  14. newdim = [prod(msize(1:num)) msize(num+1:end)];
  15. % do the reshape
  16. f = reshape(m,[newdim 1]); % tack on a 1 to handle the special case of squishing everything together