title: How to vertically stack blocks of an nD array?
body: <p>I have a 5D array A and want to vertically stack the blocks
  A(x,y,z,:,:) for all x, y and z. I have done the following:</p>
  
  <pre><code>    A = rand(128, 128, 64, 20, 3);
      a = 1; 
      for z = 1:Z
         for y = 1:Y
             for x = 1:X
                 res(a:a+T-1,:) = squeeze(A(x,y,z,:,:));
                 a = a + T;
             end
         end
      end
  </code></pre>
  
  <p>While correct, it appears that this computation is quite slow for my purpose.
  Can anyone figure out how to achieve the same goal more efficiently?</p>