Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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: 5,922
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$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
Read Re: Cumulative sum
Barry Shaw
1/28/13
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]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.