LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get all possible combinations from two arrays

Solved!
Go to solution

Hi,  

There are two arrays and I want to get all possible combinations

array 1= a , b, c, d...

array 2=x ,y ,z.....

array 3= a  x

               a y

               a z

               b x

               b y

              ..........                  

0 Kudos
Message 1 of 9
(5,137 Views)
Solution
Accepted by topic author rojartom

Hi rojartom,

 

when all LabVIEW beginners would take the free online resources offered by NI they surely would know how to use the autoindexing of arrays in loops:

check.png

With recent LabVIEW versions this would be even easier as you would have access to "concatenating output tunnels" - but it seems you're stuck with LV8.2…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(5,091 Views)

Hello,

 

I have question, it is possible to modify this solution to this kind of problem. I need combination of 2 arrays each with 2 columns. So the elements of each row of array will stay together.

dominikv_0-1583164376150.png

 

Thank you in advance.

 

DV

0 Kudos
Message 3 of 9
(3,610 Views)

Have you tried to apply your 2-D arrays to the example shown above for 1-D arrays?

 

You'll find when you auto-index a 1-D array, it takes it 1 element at a time.  When you auto-index a 2-D array, it takes it 1 row at at time.

 

You may need to change the way the array is built inside the inner most For Loop to Concatenate mode.  But if you play around and experiment, I think you'll find the solution you want is not that much different than the one already presented!

0 Kudos
Message 4 of 9
(3,606 Views)

Thank you, I tried solution you suggested but I get different format of solution. 

 

dominikv_0-1583176331177.png

dominikv_1-1583176359529.png

 

 

0 Kudos
Message 5 of 9
(3,586 Views)

Hi Dominik,

 

when you want to append row from array1 with row of array2 you should change the mode of IndexArray in the inner loop to concatenating.

And you don't need the outer loop for your next try…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 9
(3,581 Views)

Gerd is correct.

 

And if you go back to my message, you'll see I said "You may need to change the way the array is built inside the inner most For Loop to Concatenate mode" 😉

0 Kudos
Message 7 of 9
(3,558 Views)

Also don't forget the concatenating tunnel, greatly simplifying things:

 

altenbach_0-1583210710479.png

 

Message 8 of 9
(3,544 Views)

Thank you very much for your help. That is what I have looked for.

0 Kudos
Message 9 of 9
(3,530 Views)