How to index a temporary matrix?
<p>When I want to access a specific element of a matrix, I use indexing with parentheses:</p>

<pre><code>m = calc_stuff(...);
x = m(index1, index2);
</code></pre>

<p>However, I often want to do that in one line of code, like this:</p>

<pre><code>x = calc_stuff(...)(index1, index2);
</code></pre>

<p>How can I express it?</p>

<p>A specific example:</p>

<pre><code>m = cumsum(rand(10,4));
x = m(10, 1);
</code></pre>

<p>The above script calculates some sums of random variables, and then I take one example value out of the result matrix.</p>

<p>How could I write it as one line? The following doesn't work:</p>

<pre><code>x = cumsum(rand(10,4))(10, 1);
</code></pre>

<blockquote>
  <p>Error: ()-indexing must appear last in an index expression.</p>
</blockquote>

<p>Here, I want a general syntax, which is applicable for any calculation, not necessarily involving random variables.</p>