LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Solved!
Go to solution
Highlighted

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!

0 Kudos
Message 1 of 3
(3,159 Views)
Highlighted
Solution
Accepted by topic author PSerial

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,142 Views)
Highlighted

Thanks, that works great! 🙂

0 Kudos
Message 3 of 3
(3,127 Views)