How to generate all permutations of numbers if I have a number twice?

조회 수: 3 (최근 30일)
Mr M.
Mr M. 2018년 7월 7일
답변: Paolo 2018년 7월 7일
I cannot use perms([1 2 2]) because I dont want 1,2,2 twice.

답변 (1개)

Paolo
Paolo 2018년 7월 7일
How about calling unique function after perms?
data = unique(perms([1 2 2]),'rows');
data =
1 2 2
2 1 2
2 2 1

카테고리

Help CenterFile Exchange에서 Discrete Math에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by