Main Content

celldisp

Display cell array contents

Description

example

celldisp(C) recursively displays the contents of a cell array.

The celldisp function also displays the name of the cell array. If there is no name to display, then celldisp displays ans instead. For example, if C is an expression that creates an array, then there is no name to display.

example

celldisp(C,displayName) uses the specified display name instead of the default name described in the previous syntax.

Examples

collapse all

Create a cell array.

C = {'row1',[1 2 3],3+4i;
     'row2',[2 4;1 3],{'innercells',42}}
C=2×3 cell array
    {'row1'}    {[   1 2 3]}    {[3.0000 + 4.0000i]}
    {'row2'}    {2x2 double}    {1x2 cell          }

Display the contents of each cell using the celldisp function. celldisp also displays the curly-brace indexing you can use to index into cells.

celldisp(C)
 
C{1,1} =
 
row1
 
 
C{2,1} =
 
row2
 
 
C{1,2} =
 
     1     2     3

 
 
C{2,2} =
 
     2     4
     1     3

 
 
C{1,3} =
 
   3.0000 + 4.0000i

 
 
C{2,3}{1} =
 
innercells
 
 
C{2,3}{2} =
 
    42

 

The last cell contains a cell array. celldisp also displays the contents of each cell from the inner cell array.

Call celldisp and specify a cell array as its first input argument. Since the first argument is not a workspace variable, and so does not have a name of its own, specify a name as the second argument. celldisp displays the cell array using this name.

celldisp({'row1',5,10},'myCells')
 
myCells{1} =
 
row1
 
 
myCells{2} =
 
     5

 
 
myCells{3} =
 
    10

 

Call celldisp without specifying a name. When there is no variable name or second input argument, celldisp displays ans as the name of the cell array.

celldisp({'row1',5,10})
 
ans{1} =
 
row1
 
 
ans{2} =
 
     5

 
 
ans{3} =
 
    10

 

Input Arguments

collapse all

Input cell array.

Displayed name of the cell array, specified as a character vector or string scalar.

Extended Capabilities

Version History

Introduced before R2006a