Main Content

strlen

Determine length of string

Description

example

L = strlen(str) returns the number of characters in the string str.

Note

The operator strlen is supported only in Stateflow® charts that use C as the action language. In charts that use MATLAB® as the action language, use strlength.

Examples

expand all

Return a value of 13, the number of characters in the string.

str = "Hello, world!";
L = strlen(str);

Stateflow chart that uses the strlen operator in a state.

Tips

  • Enclose literal strings with single or double quotes.

Version History

Introduced in R2018b