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 page 3-28.

The following table lists the MATLAB C++ Math Library routines to create character arrays and perform some basic tasks with 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 MATLAB C++ Math Library Reference.

Table 3-3: Character Array Routines 
To ...
Use ...
Create a character array
mwArray string constructor:
  mwArray("abcd")
Create a character array from a numeric array
char_func()

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

Concatenate character strings into a multidimensional, blank-padded character array
str2mat()
strcat()
strvcat()
Convert an array of blank-padded character strings into a cell array of strings
cellstr()
Concatenate character strings into a cell array of strings
char_func()
Remove extra blank characters from individual rows in a character array.
deblank()
Display a character string.
disp()
Convert a number to its string representation, specifying format.
num2Str()
Round the elements in an array to integers and convert the results into a string matrix.
int2str()
Convert character string into a numeric array.
str2num()


 Evaluating Arrays for Sparse Storage Creating MATLAB Character Arrays