AllCombIter
An iterative approach to compute all the combinations amnong undetermined number of 1D arrays.
Mr. Jos (https://www.mathworks.com/matlabcentral/fileexchange/10064-allcomb-varargin) supplied a function `allcomb` which compute combinations of several arrays.
While the `allcomb` function return all of the combinations in a matrix form at once, it may crash when the number of combinations reachs a high level (i.e. run out of memeory).
A iterative version of `allcomb` is design to be a iterator-like object, it only return one combination when the method `next()` is called.
Notice that, it only compute the comb of 1D arrays!
Technically, it use a recursive approach in place of an undetermined nested of for-loop
Example:
A_range = 0:2:6;
B_range = 0:2:4;
C_range = 1:2;
iter = AllCombIter(A_range, B_range, C_range);
cmb = [];
while iter.hasNext()
comb = iter.next();
cmb = [cmb; comb];
end
Cite As
一平 左 (2024). AllCombIter (https://www.mathworks.com/matlabcentral/fileexchange/89117-allcombiter), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0 |