strcat
Concatenate strings horizontally
Syntax
Description
s = strcat(
horizontally
concatenates the text in its input arguments. Each input argument can be a character
array, a cell array of character vectors, or a string array.s1,...,sN
)
If any input is a string array, then the result is a string array.
If any input is a cell array, and none are string arrays, then the result is a cell array of character vectors.
If all inputs are character arrays, then the result is a character array.
For character array inputs, strcat
removes trailing ASCII
whitespace characters: space, tab, vertical tab, newline, carriage return, and form
feed. For cell array and string array inputs, strcat
does not
remove trailing white space.
For faster performance and to preserve trailing whitespace characters, use append
.
Examples
Input Arguments
Alternative Functionality
The
append
function can be used in place ofstrcat
to preserve trailing whitespace characters.Character arrays also can be concatenated using left and right square brackets.
s1 = 'Good '; s2 = 'Morning'; s = [s1 s2]
s = Good Morning
String arrays can also be concatenated using the
+
operator.s1 = "Good "; s2 = "Morning"; s = s1 + s2
s = Good Morning
Extended Capabilities
Version History
Introduced before R2006a