Concatenate strings horizontally




s = strcat(s1,...,sN) horizontally concatenates strings s1,...,sN. Each input argument can be a single string, a collection of strings in a cell array, or a collection of strings in a character array.

If any input argument is a cell array, the result is a cell array of strings. Otherwise, the result is a character array.

For character array inputs, strcat removes trailing ASCII white-space characters: space, tab, vertical tab, newline, carriage return, and form feed. For cell array inputs, strcat does not remove trailing white space.


collapse all

Concatenate Two Strings

s1 = 'Good';
s2 = 'morning';
s = strcat(s1,s2)
s =


Concatenate Two Cell Arrays

s1 = {'abcde','fghi'};
s2 = {'jkl','mn'};
s = strcat(s1,s2)
s = 

    'abcdejkl'    'fghimn'

Concatenate Two Cell Arrays with Scalar Cell Array

firstnames = {'Abraham'; 'George'};
lastnames = {'Lincoln'; 'Washington'};
names = strcat(lastnames, {', '}, firstnames)
names = 

    'Lincoln, Abraham'
    'Washington, George'

Input Arguments

collapse all

s1,...,sN — Input stringscharacter arrays | cell array of strings

Input strings, specified as cell arrays of strings or character arrays with the same number of rows. When combining nonscalar cell arrays and multirow character arrays, cell arrays must be column vectors with the same number of rows as the character arrays.

Data Types: char | cell

More About

expand all


  • Strings also can be concatenated using left and right square brackets.

    s1 = 'Good ';
    s2 = 'Morning';
    s = [s1 s2]
    s =
    Good Morning

See Also

| | | |

Introduced before R2006a

Was this topic helpful?