# bitsliceget

Get consecutive slice of bits

## Description

example

c = bitsliceget(a) returns the entire set of bits in the fixed-point input a.

example

c = bitsliceget(a, lidx) returns a consecutive slice of bits from a, starting at position lidx and ending at the LSB (the bit at position 1).

example

c = bitsliceget(a, lidx, ridx) returns a consecutive slice of bits from a, starting at position lidx and ending at position ridx.

The bitsliceget arguments must satisfy the following condition:

a.WordLength >= lidx >= ridx >= 1

## Examples

collapse all

### Get Entire Set of Bits

Begin with the following fixed-point number.

a = fi(85,0,8,0);
disp(bin(a))
01010101

Get the entire set of bits of a.

c = bitsliceget(a);
disp(bin(c))
01010101

### Get a Slice of Consecutive Bits with Unspecified Endpoint

Begin with the following fixed-point number.

a = fi(85,0,8,0);
disp(bin(a))
01010101

Get the binary representation of the consecutive bits, starting at position 6.

c = bitsliceget(a,6);
disp(bin(c))
010101

### Get a Slice of Consecutive Bits with Fixed-Point Indexes

Begin with the following fixed-point number.

a = fi(85,0,8,0);
disp(bin(a))
01010101

Get the binary representation of the consecutive bits from fi(6) to fi(2).

c = bitsliceget(a,fi(6),fi(2));
disp(bin(c))
01010

### Get a Specified Set of Consecutive Bits from Each Element of a Matrix

Begin with the following unsigned fixed-point 3-by-3 matrix.

a = fi([2 3 4;6 8 2;3 5 1],0,4,0);
disp(bin(a))
0010   0011   0100
0110   1000   0010
0011   0101   0001

Get the binary representation of a consecutive set of bits of matrix a. For each element, start at position 4 and end at position 2.

c = bitsliceget(a,4,2);
disp(bin(c))
001   001   010
011   100   001
001   010   000

## Input Arguments

collapse all

### a — Input arrayscalar | vector | matrix | multidimensional array

Input array, specified as a scalar, vector, matrix, or multidimensional array of fixed-point fi objects. If a has a signed numerictype, the bit representation of the stored integer is in two's complement representation.

Data Types: fixed-point fi

### lidx — Start position for slicescalar

Start position of slice specified as a scalar of built-in type. lidx represents the position in the slice closest to the MSB.

Data Types: fi|single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

### ridx — End position for slicescalar

End position of slice specified as a scalar of built-in type. ridx represents the position in the slice closest to the LSB (the bit at position 1).

Data Types: fi|single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

## Output Arguments

collapse all

### c — Output arrayscalar | vector | matrix | multidimensional array

Fixed-point fi output, specified as a scalar, vector, matrix, or multidimensional array with no scaling. The word length is equal to slice length, lidx-ridx+1.

If lidx and ridx are equal, bitsliceget only slices one bit, and bitsliceget(a, lidx, ridx) is the same as bitget(a, lidx).