Constuctiing special array (like binary)
古いコメントを表示
Hi, I'am new to matlab and I want to make an nxn matrix containing as first row zeros and as last row ones. The other rows should be like binary digits.
Example with n=4:
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
Thank you!!
2 件のコメント
Matt J
2013 年 12 月 4 日
The matrix you've shown is not nxn. It is 2^n x n.
Dimitris Sideratos
2013 年 12 月 5 日
採用された回答
その他の回答 (3 件)
Andrei Bobrov
2013 年 12 月 4 日
編集済み: Andrei Bobrov
2013 年 12 月 4 日
rem(floor((0:pow2(n)-1)'*pow2(1-n:0)),2)
Dimitris Sideratos
2014 年 1 月 19 日
0 投票
2 件のコメント
Jan
2014 年 1 月 19 日
Please open a new thread for a new question.
Dimitris Sideratos
2014 年 1 月 20 日
Jos (10584)
2014 年 1 月 20 日
編集済み: Jos (10584)
2014 年 1 月 20 日
Take a look at COMBN:
USe like this:
N = 2 ; M = 3 ;
combn(0:M-1,N)
カテゴリ
ヘルプ センター および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!