Using the C++ Math Library    

Displaying the Contents of a Cell Array

The C++ output operator (<<) is used to direct a value to an output stream such as the predefined ostream cout (standard output). For numeric arrays, the output operator displays the contents of each array element. However, for cell arrays, the output operator displays the contents of a cell only if the value stored there is a MATLAB character array or scalar array. For cells containing multidimensional arrays, cell arrays or other MATLAB arrays, the output operator only displays the size of the array stored in the cell.

To display the contents of each cell in a cell array, you must use the celldisp() routine. To illustrate, the following code fragment creates a cell array that contains a MATLAB character array, a scalar array, and several multidimensional arrays. The example then prints out the cell array using the output operator and celldisp().

This code produces the following output:


 Creating Cell Arrays MATLAB Structures