KCOMBSN

版本 1.2.0.0 (946 字节) 作者: Eric Schols
Returns k random combinations of p unique integers between 1 and N.
46.0 次下载
更新时间 2016/1/13

查看许可证

C = KCOMBSN(N,k,p) returns the k-by-p matrix C consisting of k random combinations of p unique integers between 1 and N.
Note that:
1. N, k and p should be positive integers, with p < N.
2. There are at most nchoosek(N,p) combinations of p unique integers between 1 and N, therefor k <= nchoosek(N,p).
Example: The following code:
N = 9;
k = 3;
p = 4;
C = kcombsn(N,k,p);

could return the following matrix C:

5 3 9 6
1 6 5 2
5 6 4 2

NB: This code circumvents taking a subset of all possible combinations, as constructing all possible combinations, e.g. using nchoosek(1:N,p), easily runs into memory issues.

引用格式

Eric Schols (2024). KCOMBSN (https://www.mathworks.com/matlabcentral/fileexchange/54876-kcombsn), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2015a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Arithmetic Operations 的更多信息
致谢

参考作品: KTHCOMBN

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.2.0.0

Improved the input checks.

1.1.0.0

Fixed the ugly alignment in the description (due to copying it from MATLAB)

1.0.0.0