LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I need to perform a union of two arrays to see what are the common items in both

I need to find the items that are common in two separate arrays.  Is there a union operator for arrays or an intersection operator?  The example on the forums is written in an older version of labview and I cant open it.

0 Kudos
Message 1 of 14
(5,590 Views)

@id wrote:

The example on the forums is written in an older version of labview and I cant open it.


Link to the old example?

 

 

0 Kudos
Message 2 of 14
(5,576 Views)

Why in the world would you want to compute the union?  The union will merge the two arrays into one and lose any information about which elements existed in the two original sets.  That won't help you find out what was common to both at all.  You're on the right track with the intersection.  THAT is what you want to compute.

 

Here's an example from LAVA assuming your arrays are pre-sorted: https://lavag.org/topic/13187-computing-array-intersections/

I'm guessing this is the example you're referencing: http://www.ni.com/example/28766/en/ 

 

If so, post it in the version conversion forums and I'm sure someone will take the time to help you convert it.  I don't have 8 installed on this computer so I'd be useless in converting it if this is the example you're talking about.  If not, give it a try.

0 Kudos
Message 3 of 14
(5,563 Views)

@id wrote:

I need to find the items that are common in two separate arrays.  Is there a union operator for arrays or an intersection operator?  The example on the forums is written in an older version of labview and I cant open it.


In any case, this seems like quite a trivial task?

What is the datatype of the arrays?

Are there possibly duplicate elements?

Should the output be a sorted array of the common elements?

How big are the arrays?

 

What have you tried? Seems like a good exercise. 😄

0 Kudos
Message 4 of 14
(5,531 Views)

@id wrote:

I need to find the items that are common in two separate arrays.


There are many ways to do this. One easy solution would use variant attriibutes, e.g. as follows:

 

 

Message 5 of 14
(5,515 Views)

That, Christian, is why you are a Knight of NI!  A very elegant solution, but I suspect the Original Poster is a student just learning LabVIEW and wanting to learn how Arrays work.  I must confess when I read "One easy solution would use variant attriibutes", my reaction was "What??!!" -- it is certainly something that wouldn't occur to me right away!

 

Bob Schor

0 Kudos
Message 6 of 14
(5,492 Views)

 

Thank you sir.I was looking for a compact codefunction like this arrangement. I was wondering if it was hidden in an add on toolkit oe something that I hadnt enabled.

0 Kudos
Message 7 of 14
(5,457 Views)
Just plain LabVIEW, no toolkit. Wrap it in a subVI if you like.
0 Kudos
Message 8 of 14
(5,421 Views)

sir can you tell me how u combined 2 auto-indexing in the for loop together

looks like string will b inserted in the array only if boolean auto-indexing is true

im using LabVIEW 2010

0 Kudos
Message 9 of 14
(5,395 Views)

You can use the search 1D array fucntion and a for loop

 

 

Regards

Abraham Kurien

CLD

Captronic Systems

 

Message 10 of 14
(5,387 Views)