フィルターのクリア

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 Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by