Binary Bit Masking

36 visualizzazioni (ultimi 30 giorni)
Nevin
Nevin il 16 Nov 2011
Risposto: Fangjun Jiang il 17 Ago 2018
What is the easiest way to bit mask a 16 bit binary value to decode different fields (2 bit, 4 bit, etc) with it? Thanks

Risposta accettata

Fangjun Jiang
Fangjun Jiang il 16 Nov 2011
bitand(), bitor(),

Più risposte (2)

Walter Roberson
Walter Roberson il 16 Nov 2011
You could use bitand() and bitshift() too. Or just bitget().
Watch out for the bit numbering order that MATLAB uses.
  3 Commenti
Fangjun Jiang
Fangjun Jiang il 16 Nov 2011
You can get multiple bits.
bitget(7,1:3)
thinnawat chumpuwiset
thinnawat chumpuwiset il 17 Ago 2018
i'm still confuse about bitget(), can you describe more detail?

Accedi per commentare.


Fangjun Jiang
Fangjun Jiang il 17 Ago 2018
>> dec2bin(7,8)
ans =
'00000111'
>> bitget(7,1:8)
ans =
1 1 1 0 0 0 0 0

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by