How can I generate all possible combinations from multiple sets of nchoosek?
5 次查看(过去 30 天)
显示 更早的评论
Basically, I want to run combntns on multiple sets. Given multiple vectors and knowing how many elements to choose from each vector, can I generate all possible combinations? I suppose it can be done with for loops, but I am hoping for something more elegant.
Example
If
n1 = [1,2,3]; k1 = 1;
n2 = [4,5,6]; k2 = 2;
then
c = [1 4 5
1 4 6
1 5 6
2 4 5
2 4 6
2 5 6
3 4 5
3 4 6
3 5 6]
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!