Using the C Math Library    

Accessing Individual Strings in an Array of Strings

You can manipulate multidimensional character arrays just as you would a standard MATLAB numeric array. For example, to extract an individual string from a character array, use standard MATLAB indexing syntax. Note, however, that a string extracted from a character array in this fashion may contain blank padding characters. To remove these blank characters from the character array, use the mlfDeblank() routine.

The following code fragment extracts the string "my dog" from the character array, A, created in the previous section. This is equivalent to the MATLAB statement B = A(2,:). The example displays the size of the extracted array, B, before and after removing blanks. Note that the index format string is passed as a standard C string; it does not need to be a MATLAB character array.

This code produces the following output.


 Creating MATLAB Character Arrays Cell Arrays