Pack Data

Pack an array of integers into an array of bytes

Syntax

out = packData(in,datatype,datasize)

Description

out = packData(in,datatype,datasize) packs input integer data with the specified data type "datatype" and data size "datasize" into an array of uint8 bytes.

Data Type

Input can be any of the following supported int data types:

*when uint8 is specified, the input is passed through

Data Size

Input data must be a 1-dimensional array. There is no limit to the length of the array.

Packaging Protocol

To find out how data is packaged, see the following Packaging Protocol documentation.

Code Generation

This function is supported for code generation. It can be be used in a Simulink model, deployed to a target, or converted into a standalone executable or mex file.

Example

Packing an array of two int8 integers

>> out = packData([-127 127],'int8',2);

Result:

out = [255 254]

See Also

Unpack Data