strvcat

(Not recommended) Concatenate strings vertically

strvcat is not recommended. Use char instead. Unlike strvcat, the char function does not ignore empty character vectors.

Syntax

S = strvcat(t1, t2, t3, ...)
S = strvcat(c)

Description

S = strvcat(t1, t2, t3, ...) forms the character array S containing the character arrays t1,t2,t3,... as rows. Spaces are appended to each input argument as necessary so that the rows of S have the same number of characters. Empty arguments are ignored.

S = strvcat(c) when c is a cell array of character vectors, passes each element of c as an input to strvcat. Empty character vectors in the input are ignored.

Examples

The command strvcat('Hello','Yes') is the same as ['Hello';'Yes '], except that strvcat performs the padding automatically.

t1 = 'first'; t2 = 'character'; t3 = 'array'; t4 = 'second';

S1 = strvcat(t1, t2, t3)

S1 =

  3×9 char array

    'first    '
    'character'
    'array    '

S2 = strvcat(t4, t2, t3)

S2 =

  3×9 char array

    'second   '
    'character'
    'array    '

S3 = strvcat(S1, S2)

S3 =

  6×9 char array

    'first    '
    'character'
    'array    '
    'second   '
    'character'
    'array    '

Tips

If each text parameter, ti, is itself a character array, strvcat appends them vertically to create arbitrarily large character arrays.

Introduced before R2006a