LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I add columns individually in a 2D array?

hi! i am reading out a CCD chip and generating 2D .txt files of the data. Howeverm I need to add up all the values from column 1,and write that value to a new file (starting a new column in a new .txt file). then i must add all of the val's from col. 2, and append that result to the new file etc etc until all the columns are added, and the results written to that new .txt file,which is then saved- How do I do the addition :-S
Cheers!
John
0 Kudos
Message 1 of 3
(4,185 Views)
Read the 2D-array, with the "Index Array" function you can access the particular column of the 2D array you want to add (index array function is resizable). Wire the input from index array function to the "Add Array Elements" function to obtain the sum for that column.
0 Kudos
Message 2 of 3
(4,185 Views)
john-

you said you already have the 2D data in a text file, i guess some comma delimeted spreadsheet compatible file? labview has a "Read From Spreadsheet File" vi, and it should import your data right into a 2D labview array. then to sum up the columns, first you probably want to transpose that array, then wire it to a single FOR loop, enabling indexing.

the value that gets passed inside will be a 1D array that is a slice of the 2D array. wire that to a "Sum 1D Array" vi from the math menu, then wire the output to the other edge of the FOR loop, and make sure indexing is enabled. then wire that output to a "Write To Spreadsheet File" using the 1D array input. it should process very fast, and you just have to wire up some stuff like the file path and deli
meters and stuff. did that explain it well enough?

micah
0 Kudos
Message 3 of 3
(4,185 Views)