Hello!
Now I am trying to make functions to form a matrix which can traverse all the values of input. Can you help with that?
Suppose that we have three arrays:
as = [1,2]
bs = [3,4, 5]
cs = [6]
Then I want to build a matrix that includes all the possible combinations
nloop = length(as) * length(bs) * length(cs)
num_set = zeros(nloop, 3)
loop_num = 1
for (ia, va) in enumerate(as), (ib, vb) in enumerate(bs), (ic, vc) in enumerate(cs)
num_set[loop_num, :] .= [va,vb,vc]
global loop_num += 1
end
then output should be:
6Ă—3 Matrix{Float64}:
1.0 3.0 6.0
2.0 3.0 6.0
1.0 4.0 6.0
2.0 4.0 6.0
1.0 5.0 6.0
2.0 5.0 6.0
What if I have few inputs of sets, for example:
as = [1,2]
bs = [3,4, 5]
cs = [6]
ds = [7, 8, 9]
How can I create a function to form a few loops according to the number of number sets? Many thanks in advance!