About Site Map Submit Contact Us Log in | Create an account
Create an account Log In
Average Rating
User Rating:
Visitors Rating:
My rating:

Write review
See full specifications

scripts default iconNCHOOSE (Scripts) Publisher's description

NCHOOSE - all combinations of the elements

NCHOOSE - all combinations of the elements of a set
W = nchoose(S) returns all possible combinations of one or more
elements of the set S. In total there are 2^N-1 combinations, where N
is the number of elements in S. W is a cell array: each cell holds one
of these combination (as a row vector). S can be a cell array of
strings, and each cell of W will then contain a cell array of strings.

nchoose([2 4 6 8])
% -> { [2] ;
% [4] ;
% [2 4] ;
% [6] ;
% ...
% [2 6 8] ;
% [4 6 8] ;
% [2 4 6 8]} ; % in total (2^4)-1 = 15 different combinations

- For sets containing more than 18 elements a warning is given, as this
can take some time. On my PC, a set of 20 elements took 20 seconds. Hit Ctrl-C to intterupt calculations.
- If S contain non-unique elements (e.g. S = [1 1 2]), NCHOOSE will return non-unique cells. In other words, NCHOOSE treats all elements of S as being unique. One could use NCHOOSE(UNIQUE(S)) to avoid that.
- Loosely speaking, NCHOOSE(S) collects all output of multiple calls to NCHOOSEK(S,K) where K is looping from 1 to the number of elements of S. The implementation of NCHOOSE, however, does rely of a different method and is much faster than such a loop.
- By adding an empty cell to the output, the power set of a cell array
is formed:
S = {1 ; 'hello' ; { 1 2 3}}
PowerS = nchoose(S)
PowerS(end+1) = {[]}
See: http://en.wikipedia.org/wiki/Power_set

and COMBN, ALLCOMB on the File Exchange

System Requirements:

MATLAB 6.5 (R13)
Program Release Status: New Release
Program Install Support: Install and Uninstall

NCHOOSE (Scripts) Tags:

Click on a tag to find related softwares

Is NCHOOSE (Scripts) your software?

Manage your software

Most Popular

scripts default icon ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation 1.1
ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation contain several functions for digital modulation simulation
scripts default icon Simulink Communication Labs 1.1
Simulink Communication Labs allows you to learn communication systems in greater depth.
scripts default icon M-QAM modulation and demodulation 1.1
M-QAM modulation and demodulation is the QAM modulation and demodulation tech.
scripts default icon LZW Compression/Decompression 1.1
LZW Compression/Decompression - Updated LZW compressor and decompressor with reasonable performance
scripts default icon InSPIRE utility to plot a 2D displacement field (Scripts) 1.0
This program plots the deformation field (displace vectors) contained in vector.txt.