combs: Generate all possible combinations of vector elements
Versione 1.0.0 (1,34 KB) da
Carlos Souto
Generate all possible combinations of the elements of a given vector.
Generate all possible combinations of the elements of a given vector.
table = combs(v, k) returns a matrix containing all possible combinations of the elements of vector v selected k times (includes repetitions). Matrix table has k columns and n^k rows, where n is the number of elements of vector v.
>> combs([-1, 0, 1], 3)
ans =
-1 -1 -1
-1 -1 0
-1 -1 1
-1 0 -1
-1 0 0
-1 0 1
-1 1 -1
-1 1 0
-1 1 1
0 -1 -1
0 -1 0
0 -1 1
0 0 -1
0 0 0
0 0 1
0 1 -1
0 1 0
0 1 1
1 -1 -1
1 -1 0
1 -1 1
1 0 -1
1 0 0
1 0 1
1 1 -1
1 1 0
1 1 1
Cita come
Carlos Souto (2024). combs: Generate all possible combinations of vector elements (https://www.mathworks.com/matlabcentral/fileexchange/99684-combs-generate-all-possible-combinations-of-vector-elements), MATLAB Central File Exchange. Recuperato .
Compatibilità della release di MATLAB
Creato con
R2021a
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS LinuxTag
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Scopri Live Editor
Crea script con codice, output e testo formattato in un unico documento eseguibile.
Versione | Pubblicato | Note della release | |
---|---|---|---|
1.0.0 |