Binary Bit Masking

40 次查看(过去 30 天)
Nevin
Nevin 2011-11-16
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

采纳的回答

Fangjun Jiang
Fangjun Jiang 2011-11-16
bitand(), bitor(),

更多回答(2 个)

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

请先登录,再进行评论。


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

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by