Create a vector that specifies the positions of the bits to get.

bit = [1,2,5,7,4]

bit =
1 2 5 7 4

Get the binary representation of the bits of a at the positions specified in bit.

c = bitget(a,bit)

c =
0 0 1 0 0
DataTypeMode: Fixed-point: binary point scaling
Signedness: Unsigned
WordLength: 1
FractionLength: 0

bitget returns a vector of the bits of a at the positions specified in bit. The output vector has the same length as inputs, a and bit, and a word length of 1.

Input array, specified as a scalar, vector, matrix, or multidimensional
array of fixed-point fi objects. If a and bit are
both nonscalar, they must have the same dimension. If a has
a signed numerictype, the bit representation of
the stored integer is in two's complement representation.

Data Types: fixed-point fi

bit — Bit indexscalar | vector | matrix | multidimensional array

Bit index, specified as a scalar, vector, matrix or multidimensional
array of fi objects or built-in data types. If a and bit are
both nonscalar, they must have the same dimension. bit must
contain integer values between 1 and the word length
of a, inclusive. The LSB (right-most
bit) is specified by bit index 1 and the MSB (left-most
bit) is specified by the word length of a. bit does
not need to be a vector of sequential bit positions; it can also be
a variable index value.

Output array, specified as an unsigned scalar, vector, matrix,
or multidimensional array with WordLength 1.

If a is an array and bit is
a scalar, c is an unsigned array with word length
1. This unsigned array comprises the values of the bits at position bit in
each fixed-point element in a.

If a is a scalar and bit is
an array, c is an unsigned array with word length
1. This unsigned array comprises the values of the bits in a at
the positions specified in bit.