What is my error in for loop to find the cumulative sum?

Answers (1)

To be safe, you need to set 'cumulativesum' to zero before starting in that for-loop. It might have some other value than zero from some previous operation, which would spoil the computation.
Also be aware that matlab has a function, 'cumsum', which will find the cumulative sum of a vector, as well as the cumulative sums of an array's rows or columns.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 28 Feb 2014

Answered:

on 28 Feb 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!