create an Binary matrix table
9 ビュー (過去 30 日間)
古いコメントを表示
Hi,
The result of the next line is a binary table: table= dec2bin(0:(2^4-1)) table =
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
I want to get the result as a matrix. What I need to add or change to get it in a matrix like that one:
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 1
Thanks, Henry
0 件のコメント
採用された回答
Thorsten
2015 年 9 月 15 日
That's easy:
table= dec2bin(0:(2^4-1)) - '0';
4 件のコメント
Omer Kaspi
2019 年 7 月 8 日
Hey,
I see the answer works, but my question is why does the "- '0'" part changes the outcome from a series of chars to a doube format?
Thanks!
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!