conversion from binary to decimal
2 ビュー (過去 30 日間)
古いコメントを表示
Hello, I am trying to perform binary to decimal conversion somewhere in my code and I get the following error message. can someone please help.
item=bits(i,:));% item is a row gotten from the array named bits
scale=bin2dec('item');
??? Error using ==> bin2dec at 54 Binary string may consist only of characters 0 and 1
Error in ==> QUANTIZATION_BLOCK at 121 scale=bin2dec('item');
Thanks.
0 件のコメント
採用された回答
Walter Roberson
2011 年 5 月 16 日
First of all, it would be
scale = bin2dec(item); %no quotes!
Secondly, your bit values are probably values of 0 and 1, whereas bin2dec needs values of '0' and '1'
item = char('0' + bits(i,:));
その他の回答 (1 件)
Paulo Silva
2011 年 5 月 16 日
item=bits(i,:));% item is a row gotten from the array named bits
scale=bin2dec(item);
Just removed those '', you want what's inside the variable called item not the string item
参考
カテゴリ
Help Center および File Exchange で Audio and Video Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!