How to interpret Binary '0' and '1' as Decimal 0 and 1?

조회 수: 4 (최근 30일)
hadi
hadi 2015년 3월 6일
댓글: hadi 2015년 3월 6일
Hi all,
I have the following program:
c=dec2bin(0:3,2)
sum(sum(c))
And I get the output:
c =
00
01
10
11
s =
388
Instead of having s=4.
So how can I let matlab read the zeros and ones in the c matrix as decimal values?
Thanks a lot.
Hadi.

채택된 답변

David Young
David Young 2015년 3월 6일
One way:
cdec = c - '0';
  댓글 수: 1
hadi
hadi 2015년 3월 6일
Thank you sooooo much David.... I really appreciate your help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by