Main Content

ASCII Encode

Convert Simulink values into uint8 character vector

  • Library:
  • Simulink Real-Time / RS232

  • ASCII Encode block


The ASCII Encode block generates a uint8 output vector that contains a NULL-terminated character vector based on a printf like format string. The data comes from the input ports.



expand all

Values that the block encodes as a null-terminated character vector.

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


expand all

Generated uint8 output vector that contains a NULL-terminated character vector.


expand all

Enter a printf like format string. For each format specifier such as %d, the block replaces the format specifier by the converted value in the corresponding input variable. The format specifiers follow the normal description for printf.

Programmatic Use

Block Parameter: format

The value on each port is inserted into the output character vector with the format specified in Format string.

Programmatic Use

Block Parameter: nvars

The block allocates enough memory to support this length for the output port. When specifying this length, include the NULL termination on the character vector.

If the converted character vector exceeds this length, the block returns an error and does not write that character vector to the output port.

Programmatic Use

Block Parameter: maxlength

A cell vector with the same number of elements as specified in Number of variables can specify a different data type for each input port. A single element is replicated. For example:


{ } — The three inputs are doubles.

{'uint8'} — The three inputs are uint8.

{'uint16', 'double', 'uint8'} — The first input is a uint16, the second input is a double, and the third input is a uint8.

Programmatic Use

Block Parameter: vartypes
Introduced in R2020b