combs: Generate all possible combinations of vector elements

バージョン 1.0.0 (1.34 KB) 作成者: Carlos Souto
Generate all possible combinations of the elements of a given vector.
ダウンロード: 57
更新 2021/9/22

ライセンスの表示

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

引用

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. 取得済み .

MATLAB リリースの互換性
作成: R2021a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
タグ タグを追加

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
バージョン 公開済み リリース ノート
1.0.0