Main Content

strvcat

(Not recommended) Concatenate strings vertically

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

    Description

    example

    S = strvcat(str1,...,strN)returns a character array containing the text arrays str1,...,strN 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.

    example

    S = strvcat(txt), where txt is a string array or cell array of character vectors, forms a character array containing the elements of txt as rows. The effect is like passing each element of txt as an input in the previous syntax. Empty elements in the input are ignored.

    Examples

    collapse all

    Create three character arrays of different sizes. Use strvcat to vertically concatenate the text in the arrays.

    str1 = 'First';
    str2 = 'Second';
    str3 = 'Third';
    strvcat(str1,str2,str3)
    ans = 3x6 char array
        'First '
        'Second'
        'Third '
    
    

    It is recommended to use char instead.

    char(str1,str2,str3)
    ans = 3x6 char array
        'First '
        'Second'
        'Third '
    
    

    Create a string array containing three vertical elements. Use strvcat to vertically concatenate the text in the arrays.

    txt = ["First"; "Second"; "Third"];
    strvcat(txt)
    ans = 3x6 char array
        'First '
        'Second'
        'Third '
    
    

    It is recommended to use char instead.

    char(txt)
    ans = 3x6 char array
        'First '
        'Second'
        'Third '
    
    

    Input Arguments

    collapse all

    Input text, specified as character arrays or string scalars.

    Text array, specified as a cell array of character vectors or a string array.

    Tips

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

    Introduced before R2006a