LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to build array with all combinations from a source array?

Solved!
Go to solution

Hi,

 

I have 2D array which contains Power Supply setup list defined by user. The number of PSs (array rows) is not fixed. For example - 3 PSs:

 

Name  Min    Max   Step

PS1      3.0    3.6     0.3 

PS2      0.9    1.2     0.1

PS3      1.7    1.9     0.1

 

I need to build from this list an array of all combinations as below:

 

PS1    PS2      PS3

3.0      0.9      1.7

3.0      0.9      1.8

3.0      0.9      1.9

3.0      1.0      1.7

3.0      1.0      1.8

3.0      1.0      1.9

3.0      1.1      1.7

3.0      1.1      1.8

3.0      1.1      1.9

3.0      1.2      1.7

3.0      1.2      1.8

3.0      1.2      1.9

3.3      0.9      1.7

3.3      0.9      1.8

3.3      0.9      1.9

3.3      1.0      1.7

3.3      1.0      1.8

3.3      1.0      1.9

3.3      1.1      1.7

3.3      1.1      1.8

3.3      1.1      1.9

3.3      1.2      1.7

3.3      1.2      1.8

3.3      1.2      1.9

3.6      0.9      1.7

3.6      0.9      1.8

3.6      0.9      1.9

3.6      1.0      1.7

3.6      1.0      1.8

3.6      1.0      1.9

3.6      1.1      1.7

3.6      1.1      1.8

3.6      1.1      1.9

3.6      1.2      1.7

3.6      1.2      1.8

3.6      1.2      1.9

 

How to build this array programmatically?

(Notice again that number of rows in the source array is not fixed.)

 

Thanks in advance!

Message Edited by Berezka on 12-16-2009 03:49 AM
0 Kudos
Message 1 of 5
(4,228 Views)

Hi Berezka,

 

first you have to create arrays (aka "vectors") for each PS ([3.0,3.3,3.6]; [0.9,1.0,1.1,1.2];...).

In the 2nd step you have to take the first two "vectors" to combine to a 2D array for each combination.

In the 3rd step you take the 2D array and the next "vector" to add a column in the 2D array to create again all possible combinations.

4th step: repeat 3rd step for each other "vector"

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(4,218 Views)

Thanks for a quick answer. 

 

"In the 2nd step you have to take the first two "vectors" to combine to a 2D array for each combination."

 

How to do this?

0 Kudos
Message 3 of 5
(4,209 Views)
Solution
Accepted by topic author Berezka

Hi Berezka,

 

using some auto-indexing magic:

autoindexing.png

Message Edited by GerdW on 12-16-2009 11:16 AM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 5
(4,206 Views)
GerdW, thanks!
0 Kudos
Message 5 of 5
(4,194 Views)