I am pretty new to Mathematica and to coding in general. I want to do a very specific thing, but I unable to do it.
Please explain in detail how I can make this work.
Here's the details on what I am trying to do:
I have the following matrix, which included two variables which are lists in themselves, to analyze these lists using loops I want to make a list of lists using a loop so that the OUTPUT of the function will be this:
matrix = {
{{0, 1}, {-b3 - gain11[[1]]/m, -a3 - gain22[[1]]/m}},
{{0, 1}, {-b3 - gain11[[1]]/m, -a3 - gain22[[2]]/m}},
{{0, 1}, {-b3 - gain11[[1]]/m, -a3 - gain22[[3]]/m}},
{{0, 1}, {-b3 - gain11[[2]]/m, -a3 - gain22[[1]]/m}},
{{0, 1}, {-b3 - gain11[[2]]/m, -a3 - gain22[[2]]/m}},
{{0, 1}, {-b3 - gain11[[2]]/m, -a3 - gain22[[3]]/m}},
{{0, 1}, {-b3 - gain11[[3]]/m, -a3 - gain22[[1]]/m}},
{{0, 1}, {-b3 - gain11[[3]]/m, -a3 - gain22[[2]]/m}},
{{0, 1}, {-b3 - gain11[[3]]/m, -a3 - gain22[[3]]/m}}
}
As you may have noticed, it's the same list repeated 9 times, where it fetches data from two lists, from gain11
and gain22
, each with three elements, so that all possible combinations have been made.
I have tried to use
For[i = 1, i < 4, i++,
For[j = 1, j < 4, j++, {{0, 1}, matrix = {-b3 - gain11[[i]]/m, -a3 - gain22[[j]]/m}}]]
but all that does is overwrite itself. I end up with only the last value.
Help would be appreciated.