Hi! I need to generate the combinations of elements of two arrays with different lengths. For example, if
I wish to get all combinations of elements from two arrays as
C = [1 4;1 5;2 4;2 5;3 4;3 5];
What comes to my mind is
[m,n] = meshgrid(A,B');
[C(:,1),C(:,2)] = deal(reshape(m,,1),reshape(n,,1));
Is there any more straight way to accomplish this?
And further, if I have three or more arrays to combine, what should I do?