Programming and Data Types    

Cell Arrays of Strings

It's often convenient to store groups of strings in cell arrays instead of standard character arrays. This prevents you from having to pad strings with blanks to create character arrays with rows of equal length. A set of functions enables you to work with cell arrays of strings:

For details on cell arrays see the Structures and Cell Arrays chapter.

Converting to a Cell Array of Strings

The cellstr function converts a character array into a cell array of strings. Consider the character array

Each row of the matrix is padded so that all have equal length (in this case, 13 characters).

Now use cellstr to create a column vector of cells, each cell containing one of the strings from the data array.

Note that the cellstr function strips off the blanks that pad the rows of the input string matrix.

The iscellstr function determines if the input argument is a cell array of strings. It returns a logical true (1) in the case of celldata.

Use char to convert back to a standard padded character array.


  Converting Characters to Numeric Values String/Numeric Conversion