substr

Extract substring from string

Description

example

dest = substr(str,i,n) returns the substring of length n starting at the i-th character of string str. Use zero-based indexing.

Examples

expand all

Extract substring "Stateflow" from a longer string.

str = "Stateflow rule the waves";
dest = substr(str,0,9);

Tips

  • Use in Stateflow® charts that use C as the action language.

  • Use zero-based indexing.

  • Enclose literal strings with single or double quotes.

Introduced in R2018b