title: dynamic output for ndgrid in Matlab
body: <p>I'd like to generate indices for an n-dimensional array with <em>ndgrid</em>.  Since the dimension may change, is there a way to wrap ndgrid so that the number of outputs for ndgrid is dynamic? Say for example, I want the <em>output</em> for a 2 dimension array to be:</p>
  
  <pre><code> [output{1} output{2}]=ndgrid(1:5)
  </code></pre>
  
  <p>and the <em>output</em> for a 3 dimension array to be:</p>
  
  <pre><code> [output{1} output{2} output{3}]=ndgrid(1:5)
  </code></pre>
  
  <p>so on and so forth...</p>