You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
Given a set of N items, we want to do something with all possible subsets of that set which have size K. This method iterates over those subsets in a deterministic fashion. Unlike "nchoosek" (which can return a list of all such combinations) the list of possible combinations is never generated in memory, meaning it should be possible to apply this to quite large K.
Example: to print all combinations of 6C3:
a = 1:3;
while a
disp(a);
a = nextcombi(6, a);
end
The complexity of nextcombi is O(N), so the iteration of all combinations should be O(N * nchoosek(N,K)).
Cite As
Dan Stowell (2026). nextcombi (https://www.mathworks.com/matlabcentral/fileexchange/21670-nextcombi), MATLAB Central File Exchange. Retrieved .
General Information
- Version 1.0.0.0 (712 Bytes)
-
No License
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
| Version | Published | Release Notes | Action |
|---|---|---|---|
| 1.0.0.0 |
