MATLAB Function Reference | Search  Help Desk |
strcat | Examples See Also |
t = strcat(s1,s2,s3,...)
t = strcat(s1,s2,s3,...)
horizontally concatenates corresponding rows of the character arrays s1
, s2
, s3
, etc. The trailing padding is ignored. All the inputs 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 a character array.
Given two 1-by-2 cell arrays a
and b
,
a = b = 'abcde' 'fghi' 'jkl' 'mn'the command
t = strcat(a,b)
yields:
t = 'abcdejkl' 'fghimn'Given the 1-by-1 cell array
c = {`Q'}
, the command t = strcat(a,b,c)
yields:
t = 'abcdejklQ' 'fghimnQ'
strcat
and matrix operation are different for strings that contain trailing spaces:
a = 'hello ' b = 'goodby' strcat(a,b) ans = hellogoodby [a b] ans = hello goodby
cat
Concatenate arrays
cellstr
Create cell array of strings from character array
strvcat
Vertical concatenation of strings