Generate nchoosek vectors line-by-line
2 次查看(过去 30 天)
显示 更早的评论
I would like to interate through combinations according to the code,
combos = nchoosek(1:512,6);
for c = 1:size(combos,1)
% code
end
However, the number of combinations, 2.4295e+13, is too big. Is there a way to generate the combinations line-by-line? I have no intention of running code for every single one, but I would like to index and get a specific combination for that index.
0 个评论
回答(1 个)
Bjorn Gustavsson
2022-5-28
There are loads of nchoosek functions available on the file exchange: nchoosek. Some of those should help you with this. I recall using versions by Jos, Bruno Luong, or/and Jan.
HTH
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!