title: How can all dimensions left after the specified one be preserved, without explicitly listing them?
body: <p><sup>Or equivalently, "what is the equivalent of NumPy's ellipsis indexing in Matlab"</sup></p>
  
  <p>Say I have some high-dimensional array:</p>
  
  <pre><code>x = zeros(3, 4, 5, 6);
  </code></pre>
  
  <p>I want to write a function that takes an array of size <code>(3, ...)</code>, and does some computation. In NumPy, I could write this:</p>
  
  <pre class="lang-python prettyprint-override"><code>def fun(x):
      return x[0]*x[1] + x[2]
  </code></pre>
  
  <p>However, the equivalent in MATLAB doesn't work, because indexing with one integer flattens the array to 1d</p>
  
  <pre><code>function y = fun_bad(x)
      y = x(1)*x(2) + x(3)
  </code></pre>
  
  <p>I can make this work for up to 3-dimensional arrays with</p>
  
  <pre><code>function y = fun_ok3d(x)
      y = x(1,:,:)*x(2,:,:) + x(3,:,:)
  </code></pre>
  
  <p>If I want this to work for up to 10-dimensional arrays, I can write</p>
  
  <pre><code>function y = fun_ok10d(x)
      y = x(1,:,:,:,:,:,:,:,:,:)*x(2,:,:,:,:,:,:,:,:,:) + x(3,:,:,:,:,:,:,:,:,:)
  </code></pre>
  
  <p>How can I avoid writing stupid numbers of colons here, and just make this work for any dimension? Is there some <code>x(1,...)</code> syntax that implies this?</p>
  
  <p>NumPy can use the <code>...</code> (<code>Ellipsis</code>) literal in an indexing expression to mean <em>"<code>:</code> as many times as needed"</em>, which would solve this problem.</p>