Sun 13 May 2012 03:39:24 PM UTC, comment #2:
Matlab (R2009B) says:
>> a=uint8([1,2;3 4])
a =
1 2
3 4
>> bitset(a,1,[0 1; 0 1])
ans =
0 3
2 5
and:
>> help bitset
BITSET Set bit.
C = BITSET(A,BIT) sets bit position BIT in A to 1 (on). A must be an
unsigned integer or an array of unsigned integers, and BIT must be a
number between 1 and the length in bits of the unsigned integer class
of A, e.g., 32 for UINT32s.
C = BITSET(A,BIT,V) sets the bit at position BIT to the value V.
V must be either 0 or 1.
Example:
Repeatedly subtract powers of 2 from the largest UINT32 value:
a = intmax('uint32')
for i = 1:32, a = bitset(a,32-i+1,0), end
See also BITGET, BITAND, BITOR, BITXOR, BITCMP, BITSHIFT, INTMAX.
So, it is a little unclear what if anything should be
done about this. Possibly check for valid third argument?
In any case, what was the motivation for a vector third
argument which Matlab does not officially support?
|
Sun 13 May 2012 03:01:53 PM UTC, comment #1:
The third argument is expected to be a scalar. From 'help bitset':
VAL = 0 resets and VAL = 1 sets the bits.
You can do something like this instead:
This is working correctly as it is documented. I don't think this is Matlab behavior either. Are you requesting this as a new feature?
|