如何在MATLAB中从总数N中获得K个项目的所有可能组合

编程入门 行业动态 更新时间:2024-10-13 10:25:28
本文介绍了如何在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个项目的所有可能组合

本文发布于:2023-11-29 14:14:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1646622.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:组合   总数   项目   如何在   MATLAB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!