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일

0 개 추천

bitand(), bitor(),

추가 답변 (2개)

Walter Roberson
Walter Roberson 2011년 11월 16일

1 개 추천

You could use bitand() and bitshift() too. Or just bitget().
Watch out for the bit numbering order that MATLAB uses.

댓글 수: 3

Nevin
Nevin 2011년 11월 16일
Thanks Walter. But with bitget() I can't get multiple bits just one? Correct?
Fangjun Jiang
Fangjun Jiang 2011년 11월 16일
You can get multiple bits.
bitget(7,1:3)
thinnawat chumpuwiset
thinnawat chumpuwiset 2018년 8월 17일
i'm still confuse about bitget(), can you describe more detail?

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

Fangjun Jiang
Fangjun Jiang 2018년 8월 17일

0 개 추천

>> dec2bin(7,8)
ans =
'00000111'
>> bitget(7,1:8)
ans =
1 1 1 0 0 0 0 0

제품

태그

질문:

2011년 11월 16일

답변:

2018년 8월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by