Serving the Quantitative Finance Community

 
User avatar
asd
Topic Author
Posts: 17
Joined: August 15th, 2002, 9:50 pm

Running total in matlab

July 11th, 2006, 3:22 am

I have an array eg., x=[x1 ; x2 ; x3]I want to caculate running total arrayeg., y=[x1 ; x1+x2 ; x1+x2+x3]Can someone please suggest if there is some command or function to do this? (I am doing a loop now, and wondering if there is a better way)
 
User avatar
irvingy
Posts: 0
Joined: July 14th, 2002, 3:00 am

Running total in matlab

July 11th, 2006, 4:38 am

QuoteOriginally posted by: asdI have an array eg., x=[x1 ; x2 ; x3]I want to caculate running total arrayeg., y=[x1 ; x1+x2 ; x1+x2+x3]Can someone please suggest if there is some command or function to do this? (I am doing a loop now, and wondering if there is a better way)cumsum() is the function you're looking for.
 
User avatar
asd
Topic Author
Posts: 17
Joined: August 15th, 2002, 9:50 pm

Running total in matlab

July 11th, 2006, 4:02 pm

Irvingy, Thanks a lot!