Main Content

plus, +

Concatenate strings

Description

example

newStr = str1 + str2 concatenates the strings str1 and str2.

example

newStr = plus(str1,str2) is an alternative way to execute newStr = str1 + str2.

Note

To concatenate strings in Stateflow® charts that use C as the action language, use strcat.

Examples

expand all

Concatenate strings to form "Hello, world!".

str1 = "Hello, ";
str2 = "world!";
newStr = str1 + str2;

Stateflow chart that uses the + operator in a state.

Alternatively, you can use plus to concatenate strings.

str1 = "Hello, ";
str2 = "world!";
newStr = plus(str1,str2);

Stateflow chart that uses the plus operator in a state.

Input Arguments

expand all

Input strings, specified as string scalars. Enclose literal string with double quotes.

Example: "Hello"

Limitations

Version History

Introduced in R2021b