title: Matlab - sum all elements above current
body: <p>I am trying to implement a vectorised solution in matlab for adding all elements above the current element in a vector. For eg.</p>
  
  <p>I have a vector <strong>a</strong> as follows</p>
  
  <pre><code>a =
  
     1
     2
     3
     4
  </code></pre>
  
  <p>I would like a vector <strong>b</strong> like</p>
  
  <pre><code>b =
  
      1
      3
      6
     10
  </code></pre>
  
  <p>I know this can be done very easily using a loop but I was wondering if there are indexing options which can allow me to do the same in matlab/ octave?</p>