How to split binary and convert to decimal ?

18 vues (au cours des 30 derniers jours)
Joni Saputra
Joni Saputra le 25 Oct 2018
Commenté : Joni Saputra le 25 Oct 2018
For example : aaa (3 x 16 char) = [0000001101001011;0000011010001010;0000100100111100]; I want to split the 16 bits equally into 8 bits ([0000001101001011] to [00000011 01001011]) and then the 8 bits are converted to decimal, like this : bbb = [3 75; 6 138; 9 60] Thank you for help.

Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 25 Oct 2018
aaa = ['0000001101001011';'0000011010001010';'0000100100111100'];
bbb=[aaa(:,1:8); aaa(:,9:16)];
bbb=reshape(bin2dec(bbb),3,[]);
  1 commentaire
Joni Saputra
Joni Saputra le 25 Oct 2018
Thank you Sir, that's work.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by