重複ありの順列のパターンを列挙した行列を作る方法
26 views (last 30 days)
Show older comments
1,2,3,4の数字を使って作成した8桁の数字の全てのパターンを列挙した行列を作るにはどうしたら良いですか?
例えば、[[1 1 1 1 1 1 1 1];[1 1 1 1 1 1 1 2];[1 2 3 4 1 2 3 4];.....] のように列挙されて、パターンは全部で4^8通りで、4^8行8列の行列が出来上がると思います。
0 Comments
Accepted Answer
Tomohiko
on 7 Apr 2021
1ベースの4進数を1から4^8-1まで並べるという考えで、次の方法はどうでしょうか?
double(dec2base(1:(4^8-1),4))-double('0')+1
More Answers (0)
See Also
Categories
Find more on Operating on Diagonal Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!