Main Content

String Data

Text-based values

Strings are pieces of textual data. Use strings in Stateflow® charts to control chart behavior or create natural language output. Incorporate string data in your logging, messages, and custom code workflows.

Stateflow Syntax

expand all

Create, Concatenate, and Convert

stringConvert value to string
blanksCharacter array of spaces
plusConcatenate strings
str2doubleConvert string to double-precision value

Determine Types and Properties

isletterDetermine which characters are letters
isspaceDetermine which characters are spaces
isstringDetermine if input is string
strlengthDetermine length of string

Find and Replace

containsDetermine if string contains substring
startsWithDetermine if string starts with substring
endsWithDetermine if string ends with substring
strfindFind substring within a string
extractAfterExtract substring after position
extractBeforeExtract substring before position
replaceFind and replace substrings
replaceBetweenReplace substrings between start and end points
strrepFind and replace substrings
eraseDelete substrings within strings
eraseBetweenDelete substring between start and end points
insertAfterInsert string after substring
insertBeforeInsert string before substring

Edit

lowerConvert string to lowercase
upperConvert a string to uppercase
reverseReverse order of characters in strings
stripRemove leading and trailing characters from string
strtrimRemove leading and trailing white space from string

Compare

matchesDetermine if two strings match
strcmpCompare strings (case sensitive)
strcmpiCompare strings (case insensitive)
strncmpCompare first N characters of strings (case sensitive)
strncmpiCompare first N characters of strings (case insensitive)
ascii2strConvert array of type uint8 to string
str2asciiConvert string to array of type uint8
str2doubleConvert string to double-precision value
strcatConcatenate strings
strcmpCompare strings (case sensitive)
strcpyAssign string value
strlenDetermine length of string
substrExtract substring from string
tostringConvert value to string

Topics