Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: Cumulative sum
Replies: 2   Last Post: Jan 28, 2013 6:58 AM

 Messages: [ Previous | Next ]
 Greg Heath Posts: 6,385 Registered: 12/7/04
Re: Cumulative sum
Posted: Jan 28, 2013 6:58 AM

"sam" wrote in message <ke5kpo\$gjt\$1@newscl01ah.mathworks.com>...
> I am new to Matlab and trying to create a a fairly simple matrix. one of my columns i want to be the cumualtive sum of another column. For example the below matrix, i want the next column (6) to be the cumulative sum of column 3 as it decends. so the first number will be 8 then the second number will be (8+4) 12 then the third will be (8+4+7) 19 and so on.
>
> 1 5 8 4 7
> 3 6 4 7 9
> 3 6 7 9 5
> 2 5 6 7 5
>
> i havetried various ways such as the one below but with no success, can anyone please tell me where i am going wrong?
> hewson is the name of my matrices
>
> for r = 1:20
> for c=6
> hewson (r,c) = cumsum(r,3);

Correct the RHS.

Greg

Date Subject Author
1/28/13 Barry Shaw
1/28/13 Greg Heath