LabVIEW

cancel
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
(4,344 Views)

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
(4,320 Views)

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 | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 3 of 13
(4,314 Views)

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
(4,301 Views)

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
(4,295 Views)

its always better to share code than image..

 

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 6 of 13
(4,292 Views)

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
(4,282 Views)

Modified snippetArrays.png

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 9 of 13
(4,278 Views)

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

0 Kudos
Message 10 of 13
(4,271 Views)