bitget function

조회 수: 13 (최근 30일)
Aseel H
Aseel H 2012년 3월 16일
I use bitset function to replace LSB by another bit in array
but when extract this LSB by bitget function
the result = null
for example
a = [0 1 0 1];
b = [5 3 8];
c= bitset(b,1,a);
until this no problem
after that in decoding
d = bitget(b,1);
but result of d =[0 0 0 0];
not [0 1 0 1]
so, i need know what the problem in function 'bitget'

답변 (1개)

Walter Roberson
Walter Roberson 2012년 3월 16일
bitget(b,1) is going to be the same length of b. As b is of length 3, you should not be expecting to get a vector of length 4 as the result.
Your bitset() will also fail because you are trying to set bits for 4 elements out of the 3 element vector b.
  댓글 수: 3
Walter Roberson
Walter Roberson 2012년 3월 16일
Are you sure?
>> b= [5 3 8 4]
b =
5 3 8 4
>> bitget(b,1)
ans =
1 1 0 0
Notice that you stored the result of the bitset() in to "c", but you then try to get those bits back from "b".
>> bitget(bitset([5 3 8 4],1,[0 1 0 1]),1)
ans =
0 1 0 1
Aseel H
Aseel H 2012년 3월 16일
I run your code it true but my code don't work
so, can I send my file for you

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

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by