LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

summation of array columns

Is there an easy way to create a 1D array of data which is the summation of all collums in a 2D array?
0 Kudos
Message 1 of 4
(3,267 Views)
It's very easy. Wire your 2D array to a Transpose 2D Array function. Wire the output to an Add Array Elements inside a for loop. Wire the output through the for loop. See the attached picture.
Message 2 of 4
(3,267 Views)
Arend wrote:

> Is there an easy way to create a 1D array of data which is the
> summation of all collums in a 2D array?

Wire the 2D-Array to a foor loop and let it index. The 1D-Array (which
you get thru indexing at the border of the for loop) can than just be
wired to an "Add Array Elements" (Triangular icon with the Sigma-Sign
inside in the numeric-palette). This way you get the sums.
Take a look at the attached Image of a sample.

Let the results index on the border of the loop, and you've got your
1D-Array with the sums inside.

Bye

Marco
0 Kudos
Message 3 of 4
(3,267 Views)
You have to place a Transpose 2D array function before you connect the array to the for loop and let it index (like Mr. Knutson said above) other wise you will not get the sum of the colums but the sum of the rows.

RikP
Application Engineering
National Instruments
Rik Prins, CLA, CLED
Software Development Engineer
0 Kudos
Message 4 of 4
(3,267 Views)