str2ascii - Convert string to array of type uint8 - MATLAB (original) (raw)

Main Content

Convert string to array of type uint8

Syntax

Description

`A` = str2ascii(`str`,`n`) returns array of type uint8 containing ASCII values for the firstn characters in str, wheren is a positive integer. If str has fewer than n characters, the remaining elements of A are set to 0.

Use of variables or expressions for n is not supported.

example

Note

The operator str2ascii is supported only in Stateflow® charts that use C as the action language.

Examples

expand all

Return uint8 array{72,101,108,108,111}.

str = "Hello, world!"; A = str2ascii(str,5);

Stateflow chart that uses the str2ascii operator in a state.

Tips

Version History

Introduced in R2018b