I'm trying to achieve a relatively simple matrix manipulation in MATLAB.
From two vectors, I would like to generate all the possible two-element pairs that could be produced. For example, given the following two vectors:
a = [1 2 3]
b = [4 5 6]
... I would hope to be able to produce the following:
c =
1 1 1 2 2 2 3 3 3
4 5 6 4 5 6 4 5 6
I understand that I could generate the above using an explicit loop (such as multiple repmat()
operations), but my previous experience of MATLAB suggests that there probably is a built-in function that can achieve this more quickly...
Any suggestions?