title: Matlab: creating a (k+1)-tensor from a list of k-tensors
body: <p>Assume you are given a bunch of k-tensors, for simplicity let's say they are 2-tensors/matrices:</p>
  
  <pre><code> X = rand(5,5); Y = rand(5,5);
  </code></pre>
  
  <p>Is there an idiom for combining them into a 3-tensor, where the first dimension indexes the matrix? One way to do it is </p>
  
  <pre><code>P(1,:,:) = X;
  P(2,:,:) = Y;
  </code></pre>
  
  <p>and now P has dimensions <code>2x5x5</code> as required. Is there a better way to do this?
  For example, in numpy one could simply type:</p>
  
  <pre><code>P = array((X,Y))
  </code></pre>
  
  <p>but in matlab typing <code>P=[X Y]</code> or <code>P=[X; Y]</code> would give <code>10x5</code> and <code>5x10</code> matrices respectively rather than the intended <code>2x5x5</code>.</p>