BITAND Bitwise Boolean And Operation

Section: Bitwise Operations

Usage

Performs a bitwise binary and operation on the two arguments and returns the result. The syntax for its use is
   y = bitand(a,b)

where a and b are unsigned integer arrays. The and operation is performed using 32 bit unsigned intermediates. Note that if a or b is a scalar, then each element of the other array is anded with that scalar. Otherwise the two arrays must match in size.

Example

Here we AND some arrays together
--> bitand([3 4 2 3 10 12],5)
ans = 
  <uint32>  - size: [1 6]
 
Columns 1 to 6
 1  4  0  1  0  4  

This is a nice trick to look for odd numbers

--> bitand([3 4 2 3 10 12],1)
ans = 
  <uint32>  - size: [1 6]
 
Columns 1 to 6
 1  0  0  1  0  0