LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Comparing two arrays and deleting similar elements from the larger array

Solved!
Go to solution

Hello,

 

I am trying to compare two arrays (one is larger than the other). Whenever two elements match in value I would like to delete this element from the larger array. The result being an output array that has no elements similar to the smaller array.

 

As an example:

 

large = [1,3,5,7,9]

small = [2,3,4,5]

 

output = [1,7,9]

 

In my case there are no repeated values and they are always increasing with the indices. Also, my large array has about 150 elements. I've been playing around with shift registers and for loops to no avail and am hoping for some guidance.

 

At this point I don't think posting any of my past attempts will help, but I can if you need it.

 

Thank you.

0 Kudos
Message 1 of 5
(5,005 Views)

What's your definition of "similar"? Are the arrays integer of floating point?

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

They are arrays of integers. And by similar I mean equivalent. I was being too loose with my words.

0 Kudos
Message 3 of 5
(4,994 Views)
Solution
Accepted by djhuth

Maybe something like that?

 

 

(Since the large array does not have repeated elements, you can add a +1 before going to the F terminal of the select node.. Probably not worth it. For smaller arrays you can even simplify and just brute-force search from the beginning with every iteration, eliminating the shift register and such, see below. For large arrays, it will be less efficient, because the first element of the small array will be inspected N times)

 

 

 

Download All
Message 4 of 5
(4,957 Views)

This works perfectly, just what I need.

 

Thank you.

0 Kudos
Message 5 of 5
(4,908 Views)