07-31-2014 08:41 AM
Hello!
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 (http://forums.ni.com/t5/LabVIEW/Compare-elements-in-an-array/m-p/458622). 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.
Solved! Go to Solution.
07-31-2014 09:03 AM
Like this.
07-31-2014 09:24 AM
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?
07-31-2014 09:30 AM - edited 07-31-2014 09:31 AM
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!
07-31-2014 11:27 AM
.
07-31-2014 12:38 PM
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.
07-31-2014 01:18 PM
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.
Lynn
07-31-2014 01:41 PM
Thanks a lot! Now I understand how it works...