You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
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.
Cite As
Eric Schols (2026). KCOMBSN (https://in.mathworks.com/matlabcentral/fileexchange/54876-kcombsn), MATLAB Central File Exchange. Retrieved .
Acknowledgements
Inspired by: KTHCOMBN
General Information
- Version 1.2.0.0 (946 Bytes)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
