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

 채택된 답변

Thorsten
Thorsten 2015년 9월 15일

4 개 추천

That's easy:
table= dec2bin(0:(2^4-1)) - '0';

댓글 수: 4

Henry Buck
Henry Buck 2015년 9월 15일
thanks,
Henry Buck
Henry Buck 2015년 9월 15일
Hi,
How can I print only the rows that have only two '1' bits in rows? like this one: 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0
Thanks, Henry
Thorsten
Thorsten 2015년 9월 15일
편집: Thorsten 2015년 9월 15일
That's a new question. Please open a new question.
Omer Kaspi
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개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

2015년 9월 15일

댓글:

2019년 7월 8일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by