Using the C Math Library    

Character Arrays

The MATLAB C Math Library also includes routines to create and manipulate character arrays. One-dimensional character arrays are also called strings. Multidimensional character arrays are also called arrays of strings. In an array of strings, each string must be the same length. The routines that create arrays of strings use blanks to pad the strings to the same length. In a cell array of strings, individual strings can be different lengths. For information about cell arrays, see Cell Arrays.

This table lists the MATLAB C Math Library routines used to create character arrays and perform some basic operations on them. The sections that follow provide more detail about using these routines. For more detailed information about using character arrays, see Using MATLAB. For more detailed information about any of the library routines, see the online MATLAB C Math Library Reference.

Table 3-3: Character Array Routines 
To ...
Use ...
Create a character array
mxCreateString()
Create a character array from a numeric array
mlfChar()

Convert a character array to its underlying numeric representation.
mlfDouble()

Concatenate character strings into a multidimensional, blank-padded character array
mlfStr2mat()
mlfStrcat()
mlfStrvcat()
Convert an array of blank-padded character strings into a cell array of strings
mlfCellstr()
Concatenate each character string in a cell array of strings into a multidimensional array of strings.
mlfChar()
Remove extra blank characters from individual rows in a character array.
mlfDeblank()
Display a character string.
mlfDisp(), mlfPrintMatrix()
Convert a number to its string representation, specifying format.
mlfNum2Str()
Convert an array of integers into a string array.
mlfInt2str()
Convert character string to a numeric array.
mlfStr2num()


 Evaluating Arrays for Sparse Storage Creating MATLAB Character Arrays