this will be very simple for some, but I could not find the answer on the website. Thanks in advance for your help. I have two vectors of the same length (each has 11 elements). I am trying to generate a matrix where each row of the matrix is a (different) combination of the elements of each vector, element wise.
Let's take an example with 3 element vectors, and see whether I can explain better. These are the vectors:
A = [a1 a2 a3]
B = [b1 b2 b3]
where a1, a2, a3, b1, b2, b3
are scalars.
What I would need Matlab to generate is a matrix with 8 rows and 3 columns with all combinations, element by element, so that the first elements of a row is always taken from the first element of the vector (either of the two vectors) like this:
C = [a1 a2 a3;
a1 a2 b3;
a1 b2 a3;
a1 b2 b3;
b1 a2 a3;
b1 a2 b3;
b1 b2 a3;
b1 b2 b3]
Since I will have 11 elements writing it down by hand is tedious. What the suggested link does is to create a matrix of pairs of values, which is not what I need. Thank you so much for your help!