Picking elements from a set

Gives all possibilities of picking k elements from a set of N with/without order/repetition.

現在この提出コンテンツをフォロー中です。

s = pick(V,k,Type)

Gives all possibilities of picking k elements from the set V with or without order and repetition.
V can be an array of any size and any type.
Type can have the following values: '', 'o', 'r', 'or'. 'o' means pick ordered list, 'r' means replace elements after picking.

s is an array with all picks, one per row.

Examples:

>> pick(0:1, 4, 'or')
ans =
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
...

>> pick('abcd', 2, '')
ans =
ab
ac
ad
bc
bd
cd

>> pick(1:3,3,'o')
ans =
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1

引用

Stefan Stoll (2026). Picking elements from a set (https://jp.mathworks.com/matlabcentral/fileexchange/12724-picking-elements-from-a-set), MATLAB Central File Exchange. に取得済み.

謝辞

ヒントを与えたファイル: VChooseK, VChooseKR, VChooseKO

カテゴリ

Help Center および MATLAB AnswersData Distribution Plots についてさらに検索

一般的な情報

MATLAB リリースの互換性

  • すべてのリリースと互換性あり

プラットフォームの互換性

  • Windows
  • macOS
  • Linux
バージョン 公開済み リリース ノート Action
1.0.0.0