MATLAB: Combination of 2 columns

#nchoosekcombinationMATLABmatrixpermutation

Hi, I have 2 vectors, A = 10×1, B = 6×1.
How do I create a 60×2 matrix where every element of A is matched to the element of B? Each row should reflect (A,B). Thanks! 🙂

Best Answer

[Am,Bm] = ndgrid(A,B);
M = [Am(:),Bm(:)]
Related Question