PERMPOS

バージョン 3.0.1 (2.68 KB) 作成者: Jos (10584)
all possible ordered permutations of M values in N positions
ダウンロード: 3.7K
更新 2019/5/14

ライセンスの表示

permpos(M, N) where M and N are non-negative integers produces a
logical (N!/M!(N-M)!)-by-N matrix in which each row contains a unique
permutation of M trues and (N-M) falses.

W = permpos(V, N) where V is an array with M elements a matrix W
where each row a contains the values of V in preserved order, but
uniquely permuted at the N columns. The remaining positions are set to
NaN. W = permpos(V, N, F) uses the value F rather than NaN.

[W, B] = permpos(V, ...) also returns the logical matrix B, which is
true for the positions that are filled by elements of V. Note that B
equals "permpos(numel(V),N)".

V can be a numerical array, a cell array of chars or a string
array. F (optional) should be of the same class as V.

Examples:
permpos(2, 4)
% -> [ 1 1 0 0
% 1 0 1 0
% 1 0 0 1
% 0 1 1 0
% 0 1 0 1
% 0 0 1 1 ]

permpos(1:2:3, 4) % ->
% -> [ 1 2 3 NaN
% 1 2 NaN 3
% 1 NaN 3 3
% NaN 1 2 3 ]

permpos({'a','b'}, 3, 'XX') % filler
% -> { 'a' 'b' 'XX' ; 'a' 'XX' 'b' ; 'XX' 'a' 'b'}

See also nchoosek, perms, randperm, true, false
On the file Exchange:
permn, PERMNK, permsk, allcomb, ballatsq, nones, nextpermpos

引用

Jos (10584) (2024). PERMPOS (https://www.mathworks.com/matlabcentral/fileexchange/11216-permpos), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2018b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersCharacters and Strings についてさらに検索
謝辞

ヒントを与えたファイル: NEXTPERMPOS

Community Treasure Hunt

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

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

new image

3.0

Implemented 2nd output and functionality for non-numeric inputs

2.4.0.0

small update

1.0.0.0

remove unnecessary check for input size (after review by Dmitri S.)