フィルターのクリア

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

2 ビュー (過去 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 Center および File ExchangeWaveform Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by