Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

boolean comparison of 2 1D arrays

G'day all,

 

Using 8.2, on my front panel I have a list of 5 devices that might be connected. These are cam0, cam1 up to cam4. let's call these the master array.

 

I'm using IMAQdx enumerate cameras then unbunbling to get an array of interface names found (cam3, cam4, for example.)

 

I want to compare the array of interface names found with the master array and when a camera is present, light up a boolean. I don't think this is hard but I can't get my head around the logic today. Any suggestions?

0 Kudos
Message 1 of 4
(3,302 Views)

Loop through the larger array (master).  For each element, search for that element in the other array using 1D array search.  If the index it returns is > -1, it found a match, so return True.  Otherwise False.  Output booleans to autoindexed array output.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 4
(3,301 Views)

Hi Bruce,

 

Thanks for the tip. It was enough to put me on the right road. What I actually used was a "not equal" from the search 1D array vi and put the output into a case structure with a boolean constant in each case (One T the other F). I took the booleans out of the loop to produce my boolean array.

 

Thanks for the help.

0 Kudos
Message 3 of 4
(3,287 Views)

Your comments made me think of an easier way to code it:

 

Index on your master array into a for loop.  Bring the other array in unindexed.  Use "=" to compare the array to the single element of the master array.  If one of the items matches, it will be True.  Use Or Array Elements to reduce the array of booleans to a single value that will be True if there is a match and False otherwise.  Wire this out of your for loop as an autoindexed array output.

 

This eliminates the 1D search and a comparison or two.  Looks a lot cleaner, too.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 4 of 4
(3,282 Views)