Matlab中有与、 或、 异或的操作 bitand,bitor,bitxor:
bitand
Bitwise AND
Syntax
C = bitand(A, B)
Description
C = bitand(A, B) returns the bitwise AND of arguments A and B, where A and B are unsigned integers or arrays of unsigned integers.
Examples
Example 1
The five-bit binary representations of the integers 13 and 27 are 01101 and 11011, respectively. Performing a bitwise AND on these numbers yields 01001, or 9:
C = bitand(uint8(13), uint8(27))
C =
9
Example 2
Create a truth table for a logical AND operation:
A = uint8([0 1; 0 1]);
B = uint8([0 0; 1 1]);
TT = bitand(A, B)
TT =
0 0
0 1
See Also
bitcmp, bitget, bitmax, bitor, bitset, bitshift, bitxor
请发表评论