Want a matrix of n number of columns having every possible combinations of shorten elements in its row, an example is given below.
2 ビュー (過去 30 日間)
古いコメントを表示
Deepak Kumar Sahoo
2022 年 2 月 27 日
コメント済み: Deepak Kumar Sahoo
2022 年 2 月 27 日
N = 3;
phi_mn=[dec2bin(0:2^N-1)' - '0']';
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
I want to make the same matrix having elements 0,1/2,1,3/2 instead of 0 and 1 only. So the new matrix will have 4^3 rows instaed of 2^3.
0 件のコメント
採用された回答
Walter Roberson
2022 年 2 月 27 日
編集済み: Walter Roberson
2022 年 2 月 27 日
Note: the below, as coded, is only valid up to base 10.
base = 4
digits = 3
phi_mn = dec2base(0:base^digits-1, base) - '0'
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!