Using ngrid to create a matrix listing all combinations of values from row vectors
古いコメントを表示
Hi, I have the following vectors
A= [1 2 3 4];
B= [1 2];
C= [1 2 3 6 7 8];
D= [1 3 6];
and I want to create a matrix 144x4 listing in each row 1x4 a possible combination of elements from the vectors above in the order A(i) B(j) C(h) D(k). I could use ndgrid, but I don't know how to create the final matrix listing in each row a specific combination of values.
採用された回答
その他の回答 (1 件)
Ali H.
2014 年 11 月 7 日
0 投票
Vectors = {A,B,C,D};
Combinations = combvec(Vectors{:})';
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!