本文介绍了如何在MATLAB中从总数N中获得K个项目的所有可能组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,如果[1,2,3,4,5,6]是向量,则一次3个项目的所有可能组合为
For e.g., if [1,2,3,4,5,6] is a vector, then all possible combinations of 3 items at a time is
4 5 6 3 5 6 3 4 6 3 4 5 2 5 6 2 4 6 2 4 5 2 3 6 2 3 5 2 3 4 1 5 6 1 4 6 1 4 5 1 3 6 1 3 5 1 3 4 1 2 6 1 2 5 1 2 4 1 2 3如何在MATLAB中找到它?
How do I find this in MATLAB?
推荐答案尝试一下链接.基本上,您只需要键入c = combnk(1:6,3).希望对您有所帮助.
Try this link. Basically you just need to type c = combnk(1:6,3). Hope it helps.
我提出的建议和@nash的combntns之间的区别是命令所在的工具箱bnk在统计信息"工具箱中,而combntns在映射工具箱"中.
The difference between what I proposed and @nash 's combntns is the toolbox that the commands are in. combnk is in the Statistics Toolbox, while combntns is in the Mapping Toolbox.
更多推荐
如何在MATLAB中从总数N中获得K个项目的所有可能组合
发布评论