Main Content

strlen

Determine length of string

Description

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

example

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