Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Hello everyone. I need help programming a loop that can calculate a cumulative running sum given a vector of values. For example, if cell(1,1) = 10 and cell(1,2) = 2, then the cumulative sum would be 12 and if cell(1,3)=4, then the cumulative sum would be cell(1,1)+cell(1,2)+cell(1,3)=16. I need to have a matrix that shows the incremental values in Col(1) and the cumulative sums in Col(2). I've attached a worksheet that resembles the type of data and loop format that I need to build.
Thanks!!
Solved! Go to Solution.
Perfect. Thanks for your help, Mike. I appreciate the rapid responses!!!!
Anne
Another way
Mike
To be honest that is way I would have proposed, but when looking for the function I came across the summation operator first.
I've attached a sheet showing the difference in times and also the almost insignificant difference that pre-allocating the result vector makes.
We have been across this before. Wayne, Richard and myself had a lengthy discussion about calculation speed and the methods one can undertake to improve the speed. Pre-allocating an array only seemed to offer significant benefit on large matrices.
Mike
Thanks for your help, Mike. I appreciate the rapid responses!!!!
No problem, I was just about to log off aswel.
Mike