Combination of 2 columns

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

 Accepted Answer

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

More Answers (0)

Categories

Asked:

on 14 Feb 2020

Answered:

on 14 Feb 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!