uniqueperms

버전 1.0.0 (2.47 KB) 작성자: Jos (10584)
unique permutations of a set with repetitions
다운로드 수: 266
업데이트 날짜: 2019/8/27

라이선스 보기

P = uniqueperms(V) returns all unique permutations of the N elements in the vector V. P is an array with M rows (see below) and each row of P is unique. The rows are in lexicographic order. V can be a numeric array, or cell array of strings.

Example:
uniqueperms([4 2 1 2]) % returns 12 unique permutions:
% [ 1 2 2 4 ; 1 2 4 2 ; 1 4 2 2 ; ... ; 4 2 1 2 ; 4 2 2 1]
% perms([3 2 1 2]) will return all 24 permutations of 4 elements.
uniqueperms([1 1 1 1 99]) % a 5-by-5 array, rather than a 120-by-5 array with multiple duplications

This function does not rely on perms to do the job. Similar functionality can be obtained using unique(perms(V),'rows'), but this will create a possibly large intermediate array with N! rows.
When V has J unique elements, each of which is repeated Kj times (j=1:J), then the number of unique permutations is N!/(K1!*..*KJ!)

인용 양식

Jos (10584) (2024). uniqueperms (https://www.mathworks.com/matlabcentral/fileexchange/72552-uniqueperms), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2019a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0