Documentation Center

  • Trial Software
  • Product Updates

comm.IntegerToBit System object

Package: comm

Convert vector of integers to vector of bits

Description

The IntegerToBit object maps each integer (or fixed-point value) in the input vector to a group of bits in the output vector.

To map integers to bits:

  1. Define and set up your integer to bit object. See Construction.

  2. Call step to map integers in the input vector to groups of bits in the output vector according to the properties of comm.IntegerToBit. The behavior of step is specific to each object in the toolbox.

Construction

H = comm.IntegerToBit creates an integer-to-bit converter System object™, H. This object maps a vector of integer-valued or fixed-point inputs to a vector of bits.

H = comm.IntegerToBit(Name,Value) creates an integer-to-bit converter object, H, with each specified property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1,Value1,...,NameN,ValueN).

H = comm.IntegerToBit(NUMBITS,Name,Value) creates an integer-to-bit converter object, H. This object has the BitsPerInteger property set to NUMBITS and the other specified properties set to the specified values.

Properties

BitsPerInteger

Number of bits per integer

Specify the number of bits the System object uses to represent each input integer. You must set this property to a scalar integer between 1 and 32. The default is 3.

MSBFirst

Output bit words with first bit as most significant bit

Set this property to true to indicate that the first bit of the output bit words is the most significant bit (MSB). The default is true. Set this property to false to indicate that the first bit of the output bit words is the least significant bit (LSB).

SignedIntegerInput

Assume inputs are signed integers

Set this property to true if the integer inputs are signed. The default is false. Set this property to false if the integer inputs are unsigned. If the SignedIntegerInput property is false, the input values must be between 0 and (2^N)–1. In this case, N is the value you specified in the BitsPerInteger property. When you set this property to true, the input values must be between –(2(N–1)) and (2(N–1))–1.

OutputDataType

Data type of output

Specify output data type as one of Full precision | Smallest unsigned integer | Same as input | double | single | int8 | uint8 | int16 | uint16 | int32 | uint32 | logical. The default is Full precision.

When the input signal is an integer data type, you must have a Fixed-Point Designer™ user license to use this property in Smallest unsigned integer or Full precision mode.

When you set this property to Full precision, the object determines the output data type based on the input data type. If the input data type is double- or single-precision, the output data has the same data type as the input data. Otherwise, the output data type is determined in the same way as when you set this property to Smallest unsigned integer.

When you set this property to Same as input, and the input data type is numeric or fixed-point integer (fi object), the output data has the same data type as the input data.

Methods

cloneCreate an integer-to-bit converter object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs from step method
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
stepConvert vector of integers to vector of bits

Examples

expand all

Convert random integers to 4-bit words

    hIntToBit = comm.IntegerToBit(4);
    intData = randi([0 2^hIntToBit.BitsPerInteger-1],3,1);
    bitData = step(hIntToBit,intData)
bitData =

     1
     1
     0
     1
     1
     1
     1
     0
     0
     0
     1
     0

Algorithms

This object implements the algorithm, inputs, and outputs described on the Integer to Bit Converter block reference page. The object properties correspond to the block parameters.

See Also

| |

Was this topic helpful?