LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sum 2D array

Hello,

I'm working on a labView application and I want to sum the rows of a 2D array. The array gets the data form a INI file (see example)

[22022005]
Mea_0 = 1;2;5;9;12;47;2;25;86;56;89;45;23;12;12;10;9;6;5;3;1;1;2;0;0;0;0
Mea_1 = 2;3;6;10;13;48;3;26;87;57;90;46;24;13;13;11;10;7;6;4;2;2;3;1;1;1;1
Mea_2 = 5;7;6;10;13;48;3;26;77;77;90;46;24;13;13;11;29;7;6;4;2;2;3;1;3;1;1
Mea_3 = 8;12;6;10;13;48;3;26;87;97;113;76;64;33;53;41;36;7;6;4;2;2;3;4;1;1;1
Mea_n = .....
[Sum22022005]
Sum = 16;13;23;.......

The Mea's represents histogram data , I make a undefined quantity of measurements and save this to a file.
After 24h I build a array of all this measuremnt and I want to build the sum of the fields (for example)

Row1 field1 field2 ...
+Row2 field1 field2 ...
+Row3 field1 field2 ...
+Rown field1 field2 ...
------------------------
=sum fileds........

Can anybody help me
Thomas
0 Kudos
Message 1 of 9
(8,767 Views)
Hello Tom,

there's a "Sum Array" at the math palette.
If you want to sum up the whole array just connect it.
If you want to sum only single rows/columns you have to use a for-loop to get one row after the other.#

Hope this helps,
GerdW
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(8,755 Views)
Hi Tom

If I understand correctly you want to do something similar to that in attached vi.

Neil
0 Kudos
Message 3 of 9
(8,754 Views)
Hello Neil,

almost yes. But I don't know how I can work it out, bcaus I read the spreadsheet string from the file and fill a arry inside a for loop. the result is a 3D array 😞 and here I stock.
Can you help me with the problem?

Thamks

Thomas
Thomas
0 Kudos
Message 4 of 9
(8,744 Views)
I did it. Thanks for your help. "You must speek about a problem" it's always the same 😉

Thomas
Thomas
0 Kudos
Message 5 of 9
(8,729 Views)
Hi Tom

The problem lied in the fact that if you do not specify the type of array you want in the Spreadsheet string to array vi, it will convert it into a 2D array of Floats. The trick was to return a 1D array of Floats, so you have to wire a 1D array constant (see vi attached)

Also as you will see you can get rid of the parsing of the key name, since you already have an array of strings coming from the Get Key Names.vi. Just wire it to the border of the foor Loop with auto indexing (see vi attached)

regards,
Cyril Bouton
Active LabVIEW Developper
0 Kudos
Message 6 of 9
(8,727 Views)
Oops forgot the attachment....sorry
Cyril Bouton
Active LabVIEW Developper
0 Kudos
Message 7 of 9
(8,724 Views)
Hi,

the attached vi is missing!
Thomas
0 Kudos
Message 8 of 9
(8,722 Views)
Thank you very much. It was a long way to go. But now I've understood.

Tom
Thomas
0 Kudos
Message 9 of 9
(8,714 Views)