Convert binary to decimal is not correct.

조회 수: 7 (최근 30일)
filipe
filipe 2016년 2월 25일
답변: Walter Roberson 2016년 2월 25일
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
Stephen23
Stephen23 2016년 2월 25일
What is binary_data, and what values does it have/return ?

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

채택된 답변

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by