title: Finding the last element in cumsum
body: <p>I would to use cumsum to find the sum up to 5 for example, but I want the end not all the intermediate values.</p>
  
  <p>For example:</p>
  
  <pre><code>A = [1:5];
  B = cumsum(A)
  </code></pre>
  
  <p>returns</p>
  
  <pre><code>B =
  
       1     3     6    10    15
  </code></pre>
  
  <p>I just want 15 not the rest.</p>
  
  <p>What I have tried:</p>
  
  <p><code>B = cumsum(A)(end)</code> but it gives me this error:</p>
  
  <pre><code>??? Error: ()-indexing must appear last in an index expression.
  </code></pre>