MATLAB Function Reference |
Concatenate strings horizontally
Syntax
Description
t = strcat(s1, s2, s3, ...)
horizontally concatenates corresponding rows of the character arrays s1
, s2
, s3
, etc. All input arrays must have the same number of rows (or any can be a single string). When the inputs are all character arrays, the output is also a character array.
When any of the inputs is a cell array of strings, strcat
returns a cell array of strings formed by concatenating corresponding elements of s1
, s2
, etc. The inputs must all have the same size (or any can be a scalar). Any of the inputs can also be character arrays.
Trailing spaces in character array inputs are ignored and do not appear in the output. This is not true for inputs that are cell arrays of strings. Use the concatenation syntax [s1 s2 s3 ...]
to preserve trailing spaces.
Remarks
strcat
and matrix operation are different for strings that contain trailing spaces:
Examples
Given two 1-by-2 cell arrays a
and b
,
the command t = strcat(a,b)
yields
Given the 1-by-1 cell array c = {`Q'}
, the command t = strcat(a,b,c)
yields
See Also
str2num | strcmp |
© 1994-2005 The MathWorks, Inc.