필터 지우기
필터 지우기

Binary to decimal - 8 bits at a time

조회 수: 3 (최근 30일)
Shannon Cherry
Shannon Cherry 2018년 8월 31일
댓글: Ammy 2022년 3월 7일
I have a binary data of 24 bits and I need to convert them into decimal format such that: it groups first 8 bits and outputs 1 decimal value,in the next line it groups bits 9 to 16 and outputs 2nd decimal value and in the next line it groups bits 17 to 24 and outputs 3rd decimal value.
binary = [0 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 1 1 1 0]
Expected output:
10
20
14

채택된 답변

M
M 2018년 8월 31일
You can try something like this using bin2dec :
for i=1:8:numel(binary)
decimal=bin2dec(num2str(binary(i:i+7)))
% todo : save value of decimal
end
  댓글 수: 1
Ammy
Ammy 2022년 3월 7일
@M How to save the output of above decimal?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by