Main Content

str2mat

(Not recommended) Form blank-padded character array from strings

    str2mat is not recommended. Use string instead. For additional information see, Version History.

    Description

    C = str2mat(c1,c2,c3,...) creates a character array where each input starts a new row. Inputs can be string scalars or character arrays with one or more rows. The function automatically pads each row with white-space characters so that every row has the same number of characters.

    example

    Examples

    collapse all

    Combine three character row vectors into a single character array.

    c1 = 'hello';
    c2 = '';
    c3 = 'goodbye';
    C = str2mat(c1,c2,c3)
    C =
    
      3×7 char array
    
        'hello  '
        '       '
        'goodbye'

    Input Arguments

    collapse all

    Input arrays, each specified as a string scalars or character arrays. Character arrays can include more than one row.

    Output Arguments

    collapse all

    Output array, returned as a character array.

    Version History

    Introduced before R2006a

    expand all

    See Also

    |