フィルターのクリア

Binary string must be 52 bits or less error?

1 回表示 (過去 30 日間)
Sneha P S
Sneha P S 2018 年 3 月 21 日
回答済み: Walter Roberson 2018 年 3 月 21 日
I had some values in RRbin of size 65536 x 36 and type double.Then i xor-ed them with sybin(65536 x 36 double) The result of xor operation is stored in encR(65536 x 36 logical). I need to convert the result in encR back to decimal. But when iam trying to use bin2dec(encR) there comes an error that the input must be a string. So i converted the encR to string using num2str(encR) function. The output is of form 65536 x 106 char. Please help me with this 65536 x 106 char. I didnt get it. At the same time i couldnt convert it to decimal as the error "Error using bin2dec (line 35) Binary string must be 52 bits or less." occurs. Please help me to sort it out.
  2 件のコメント
James Tursa
James Tursa 2018 年 3 月 21 日
Please show one small example of the input(s), the intermediate steps, and the desired output.
Sneha P S
Sneha P S 2018 年 3 月 21 日
編集済み: Walter Roberson 2018 年 3 月 21 日
RRbin = 0 0 0 0 0 0 0 0 0 0 1 1 1 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 (double)
sybin = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 (double)
encR = 0 0 0 0 0 0 0 0 0 0 1 1 1 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 (logical)
while converting it to string the output is
0 0 0 0 0 0 0 0 0 0 1 1 1 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
but of type char and size 1 x 106. I need to convert this back to decimal.

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 3 月 21 日
values = bin2dec(char('0' + encR))
or
values = sum(bsxfun(@times, encR, 2.^(35:-1:0)),2)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by