permutation of numbers when repetition of digits is allowed.
4 次查看(过去 30 天)
显示 更早的评论
I want to have all permutation of 3 numbers when repetition of digits are allowed.How can i have them in matrix?Am i supposed to program it or not?
Regards
0 个评论
采纳的回答
Jan
2012-12-5
编辑:Jan
2012-12-5
index = [1,1,1; 1,1,2; 1,1,3; ...
1,2,1; 1,2,2; 1,2,3; ...
1,3,1; 1,3,2; 1,3,3; ...
2,1,1; 2,1,2; 2,1,3; ...
2,2,1; 2,2,2; 2,2,3; ...
2,3,1; 2,3,2; 2,3,3; ...
3,1,1; 3,1,2; 3,1,3; ...
3,2,1; 3,2,2; 3,2,3; ...
3,3,1; 3,3,2; 3,3,3];
data = [4, 17, 21];
result = data(index);
No need to program this for such a tiny set. For larger sets search in the FileExchange for the term "permutation" and "combination".
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!