LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Math with arrays

I haven't had much experience working with arrays in labview and I'm looking for a way to do more complicated math than the "add/multiply array elements."

 

More specifically, I have a 2-D, 4 row, 3 column matrix ( lets call them x, y, and z, with elements x1, x2, x3, and x4, and the same for y and z.

I need to compute the average for the elements in the 1st and 3rd columns: (x1+z1)/2 = xz1 avg

And then I need to use that result: (xz1 avg - y1)/xz1 avg

For each row in the array.

 

Do I need to split the array into 3, one for each column, to do this?  Or is there a formula node that lets me specify which array column/row/element to use?

0 Kudos
Message 1 of 4
(5,707 Views)

All you need to use is Index Array.

 

 

Message 2 of 4
(5,696 Views)

Hi

You can use Index Array to choose one element from an array, try using context help Help>Show Context Help to see how to wire the Index Array. For further help you can also use Help>Find Example where you can find usefull examples. Index Array can be also expanded. I have posted a picture of connecting the index array.

 

Hope it will help.

0 Kudos
Message 3 of 4
(5,692 Views)

By default, autoindexing FOR loops iterate over Rows, so once you have the math for one row, simply place it inside a FOR loop and iterate over all rows.

 

Here's an example:

 

Message 4 of 4
(5,684 Views)