How populate and array whose rows were combinations and columns the different groups?(labview) -


i know question confusing i´ll try explain problem. working in labview project , 1 of things have is, after asking user number of variables , number of different values each 1 of them, create array de combinations.

lets supose have 3 different variables , example: var1, var2, var3

and number of diffent values each of them is:

var1 -> 0, 1, 2 var2 -> 11, 22 var3 -> 55, 66, 77, 88 

so, resulting array should this:

0 11 55 0 11 66 0 11 77 0 22 55 0 22 66 ... 

this way until 3 x 2 x 4 = 24 rows

taking account number of variables , values of each 1 different how can populate array?

i need how labview. many in advance.

the word you're looking "cartesian product".

you can use gmath/discrete math.llb/cartesian product of lists.vi accomplish this:

labview code

this gives intended result:

result

the way works feed cartesian product vi 1d array detailing size of several arrays want cartesian product of, , generates corresponding indices need index respective arrays create cartesian product.

all need build 2d array of (1d array of row vectors) contains information want compute cartesian product of, , 1d array shows size of each individual row vector. in labview, when build array of 1d arrays, number of columns becomes max(len(row_vector_i)), preserve length information automatic cross product, best way build 1d array of clusters, each cluster has individual 1d array, or row vector. preserves size information.

here's looks like:

cluster auto

i saved of project should compatible lv8.6, found here


Comments