Convert binary to decimal is not correct.

8 Ansichten (letzte 30 Tage)
filipe
filipe am 25 Feb. 2016
Beantwortet: Walter Roberson am 25 Feb. 2016
Hi everyone,
I have the following code
value=[bitget(binary_data(1),4:-1:1),...
bitget(binary_data(2),8:-1:1),...
bitget(binary_data(3),8:-1:1),...
bitget(binary_data(4),8:-1:1)]
value=bi2de(value,2,'left-msb')
The output is not according to what used to be. Any hints what might be the problem?
value =
Columns 1 through 25
0 1 1 0 0 0 1 1 1 0 0 0 1 1 0 1 0 1 0 1 1 1 0 0 0
Columns 26 through 28
0 0 1
value =
255
Thank you
  1 Kommentar
Stephen23
Stephen23 am 25 Feb. 2016
What is binary_data, and what values does it have/return ?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 25 Feb. 2016
value = bi2de(double(value),2,'left-msb')
You were working with uint8, so the arithmetic was being done in uint8, which "saturates" at 255.

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by