# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## How do I add 1D array elements with every iteration?

Hello,

I have a 3 iteration For Loop which gives an array of 5 elements after its executed. With every iteration of the For Loop, how do I add each element to its previous value to form a final array of the elements' cummulative sum? For example:

Array values for 1st iteration:   [A, B, C, D, E]

Array values for 2nd iteration:  [F, G, H,  I,  J]

Array values for 3rd iteration:   [K, L, M, N, O]

How can I make the Final Array to be a cummulative sum of i.e:  [(A+F+K), (B+G+L), (C+H+M), (D+I+N), (E+J+O)]?

Your help will be apreciated, Thank you!

Message 1 of 3
(3,249 Views)
Solution
Accepted by PSerial

## Re: How do I add 1D array elements with every iteration?

The Add function is polymorphic. Thus, if you feed it 2 1D arrays you'll get an array that is the sum of each element. With a loop you need to use a shift register or feedback node to keep track of the current sum.

For example:

Message 2 of 3
(3,232 Views)

## Re: How do I add 1D array elements with every iteration?

Thanks, that works great! 🙂

Message 3 of 3
(3,217 Views)