Showing results for 
Search instead for 
Did you mean: 

Compare element in two 1D arrays and store in another 1D array

Hi all!


How to compare two 1D array and if both of the 1D arrays have the same elements (eg: the first is 123456 and the second array is 123456), I want to store the data in another array. If false, it will just ignore the data and continue to check the next arrays.


Below I attached the screenshot of a part of my code.


0 Kudos
Message 1 of 13

Are you by any chance checking for palindrome numbers? Some things I noticed were that you can auto index the array inputs as well instead of indexing an input array. I don't have LabVIEW in front of me but I thought running an equals on two arrays will compare return a Boolean array in which case you will have to and the array elements. 


To answer your original question though, if you right click the auto indexing tunnel coming out of the for loop you would want to enable the conditional option (if your LabVIEW version has it) otherwise you are going to have to build that yourself using a build array and case structure. The conditional tunnel will add a Boolean input to the tunnel which will only add the output to the array if that condition is true.

Matt J
National Instruments | CLA
0 Kudos
Message 2 of 13

Do you want to store both the array or only one array  (if both array matches)

Comapre two arrays and use conditional indexing, index only if the output of array comparison is true.

Palanivel Thiruvenkadam,
Certified (LabVIEW || TestStand) Developer
0 Kudos
Message 3 of 13

Thank you for your reply.


 In my case, I want to store only one array.  Anyway, I think I got the idea already on solving that by using 'Build Array' (please suggest if you know any better ways) .


Now I'm thinking of ways to convert all elements in the array into an integer (scalar) if the case is true.


0 Kudos
Message 4 of 13

Thank you for your reply.


Yes.. I am coding a program that can output all palindrome numbers in given range.

0 Kudos
Message 5 of 13

its always better to share code than image..


Palanivel Thiruvenkadam,
Certified (LabVIEW || TestStand) Developer
0 Kudos
Message 6 of 13
0 Kudos
Message 7 of 13

Instead of "Build Array", you can directly connect the array to the loop, and select tunnel as concatinating and conditional. So your code will be looking clean.

Build Array.png

0 Kudos
Message 8 of 13

Modified snippetArrays.png

Palanivel Thiruvenkadam,
Certified (LabVIEW || TestStand) Developer
0 Kudos
Message 9 of 13

Would you mind to explain how do you set the output tunnel of the for loop?

0 Kudos
Message 10 of 13