LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding neighborhood comparisons in two arrays

Solved!
Go to solution

I was wondering whether there was any efficient way to do that.

 

Let's say I have two text files that are 1d arrays:

 

Array1:                  Array2:

0                               0

0                               0

0                               0

0                              100

100                            0

0                              100

0                                0

100                            0

0                                0

 

Basically I want something that goes through each value of array1, and if it sees a number above a certain threshold (in this case, the 100), it checks the corresponding entry n in array2, as well as n-1 and n+1. If there are numbers above a threshold in either n-1, n, or n+1, then add one to a counter variable. Otherwise do nothing.

 

So in my two arrays, there should be 1 count. Array1 and array2 will always have the same number of rows.

 

Something like this would be trivial with Java or Matlab using a for loop, but I'm not sure how to do it with LabVIEW. I can handle the if's, but I'm not sure how to represent "n-1" or "n+1".

 

 

 

0 Kudos
Message 1 of 5
(2,703 Views)
Solution
Accepted by johndoe3344

LabVIEW has for loops too.

 

Message Edited by Dennis Knutson on 01-29-2010 07:56 PM
Message 2 of 5
(2,692 Views)

And now for the requisite message:

 

To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.

0 Kudos
Message 3 of 5
(2,684 Views)
Thanks a lot. Is there a chance you could post the actual VI? I can't find some of the functions.
0 Kudos
Message 4 of 5
(2,663 Views)

Left to right:

 

Decimal String to Number

Greater Than

For Loop

Case Statement

Decrement

Index Array

Increment

Compound Arithmetic

Select

 

The for loop has a shift register and the data is wired straight through in the false case.

Take the tutorials mentioned above.

0 Kudos
Message 5 of 5
(2,657 Views)