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

1 次查看(过去 30 天)
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 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by