Documentation

Byte Packing

Construct data frames

  • Library:
  • Utilities

Description

The Byte Packing block converts one or more signals of user-selectable data types to a single vector of varying data types. The output of this block typically connects to an input port of a Send block.

For example, suppose you are packing three signals into a vector of uint8. The signals have the following attributes:

DimensionSizeType
Scalar1single
Vector3uint8
Vector3uint8

  1. Set the packed output port data type to uint8.

  2. Set the input port data type to a cell array encoding the data types:

    {'single', ['uint8'], ['uint8']}

    Use square brackets to represent vectors.

  3. Set the byte alignment value to 1.

  4. Connect the signals to the Byte Packing block.

Ports

Input

expand all

The block has from 1 to N input ports. Specify the number of input ports and their types by entering them as a cell array in the parameter Input port (unpacked) data types (cell array).

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean

Output

expand all

The block displays one output port that transmits a vector of packed data. You determine the data type of the packed data by setting Output port (packed) data type.

Data Types: single | double | int8 | uint8 | int16 | uint16 | int32 | uint32 | Boolean

Parameters

expand all

From the list, select a data type for the output port.

Specify as a cell array the data types of the input ports (unpacked) for the different input signals. The number of elements in the cell array determines the number of input ports shown by this block instance. Use square brackets in the cell array to represent vector elements.

Each element in the input signals list starts at a multiple of the alignment value, specified from the start of the vector. If the alignment value is larger than the size of the data type in bytes, the vector receives pad bytes of value 0 to fill the space.

For example, if the alignment value is 4, a uint32 receives no padding, a uint16 receives 2 bytes of padding, and a uint8 receives 3 bytes of padding.

If the model accesses the data items frequently, consider selecting an alignment value equal to the largest data type that you want to access. If the model transfers the data items frequently as a group, consider selecting an alignment value of 1, which packs the data into as small a space as possible.

See Also

Introduced in R2006a

Was this topic helpful?