Showing results for 
Search instead for 
Did you mean: 

Comparison of Elements of Two 2D Arrays

Go to solution



I am trying to compare elements of two 2D Arrays and find at least one pair of elements that are identical. Browsing the forum I found one method suggested by Altenbach ( However, it works well with 1D Arrays. That is why I rearranged the original code for my case, but unfortunately the attempt was unsuccessful. Could anyone please have a look at my VI and suggest any solution? 


Thank you.



0 Kudos
Message 1 of 8

Like this.

"If you weren't supposed to push it, it wouldn't be a button."
Message 2 of 8

Thanks for your reply!


Oh, I see.. It calculates indices of identical elements of the 2D arrays. Do you know how to make it recognizing not indices but elements themselves? 

For example, in VI I attached found indices are:


2 3 5 6 7 8         and         6 6 7 7 8 8

6 6 7 7 8 8                         2 3 5 6 7 8


So, (8,8) is common for both arrays. How can I extract this pair of elements? 


0 Kudos
Message 3 of 8

Hi Ivan,


yesterday you wanted to find elements within a certain range. Today you are looking for identical elements in two arrays…


This is essentially the very same algorithm! You compare the arrays (like you did yesterday) and use the comparison result to pick elements. When it worked fine yesterday it will work today too!

Best regards,
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

Message 4 of 8


"If you weren't supposed to push it, it wouldn't be a button."
Message 5 of 8

Thanks, paul_cardinale !


It works.. Now I see the principle. 


Sometimes, the algorithm works perfectly, but sometimes it detects only one common index.


For example, 


3 5   and  5 5 6

1 0            0 1 7


In this case (5,0) is common for both arrays. But the algorithm shows that only "5" is common. Why do u think it is happening? 


I have attached VI. 


0 Kudos
Message 6 of 8
Accepted by topic author Ivan899

5 is correct. Create indicators for the 2D I32 arrays coming out the the for loops with cluster to array inside. At row 1, column 0 of both of those arrays you will find the value 5. While this is what your code generates, it is probably not what you want.


Look at what I added at the bottom of the BD, Identical 2 and  Indices of identical on the FP.



Message 7 of 8

Thanks a lot! Now I understand how it works...

0 Kudos
Message 8 of 8