Main Content

str2mat

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

str2mat is not recommended. Use char instead.

Syntax

S = str2mat(T1, T2, T3, ...)

Description

S = str2mat(T1, T2, T3, ...) forms the character array S containing the character arrays T1, T2, T3, ... as rows. The function automatically pads each row with blanks so that every row of S has the same number of characters. Each input argument, Ti, can itself be a character array with one or more rows. This function allows for the creation of arbitrarily large character arrays. Empty character arrays are significant.

Examples

x = str2mat('36842', '39751', '38453', '90307');

whos x
  Name      Size         Bytes  Class

  x         4x5             40  char array

x(2,3)

ans =

    7

Tips

str2mat differs from strvcat in that empty character arrays produce blank rows in the output. In strvcat, empty character arrays are ignored.

Version History

Introduced before R2006a

See Also

Go to top of page