The Math Forum

Search All of the Math Forum:

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

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Greg Heath

Posts: 6,387
Registered: 12/7/04
Re: Cumulative sum
Posted: Jan 28, 2013 6:58 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"sam" wrote in message <ke5kpo$gjt$>...
> 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.


Date Subject Author
Read Re: Cumulative sum
Barry Shaw
Read Re: Cumulative sum
Greg Heath

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.