Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Cell array

A *cell array* is a data type with indexed data containers
called *cells*, where each cell can contain any type of data. Cell
arrays commonly contain either lists of text, combinations of text and numbers, or
numeric arrays of different sizes. Refer to sets of cells by enclosing indices in smooth
parentheses, `()`

. Access the contents of cells by indexing with curly
braces, `{}`

.

When you have data to put into a cell array, create the array using the cell array
construction operator, `{}`

.

```
C = {1,2,3;
'text',rand(5,10,2),{11; 22; 33}}
```

`C = `*2x3 cell array*
{[ 1]} {[ 2]} {[ 3]}
{'text'} {5x10x2 double} {3x1 cell}

You also can use `{}`

to create an empty 0-by-0 cell array.

C = {}

C = 0x0 empty cell array

To create a cell array with a specified size, use the `cell`

function,
described below.

You can use `cell`

to preallocate a cell array to which you assign data
later. `cell`

also converts certain types of Java^{®}, .NET, and Python^{®} data structures to cell arrays of equivalent MATLAB^{®} objects.

`C = cell(n)`

`C = cell(sz1,...,szN)`

`C = cell(sz)`

`D = cell(obj)`

returns a `C`

= cell(`sz1,...,szN`

)`sz1`

-by-...-by-`szN`

cell array
of empty matrices where `sz1,...,szN`

indicate the size of
each dimension. For example, `cell(2,3)`

returns a 2-by-3
cell array.

Creating a cell array of empty matrices with the

`cell`

function is equivalent to assigning an empty matrix to the last index of a new cell array. For example, these two statements are equivalent:C = cell(3,4,2); C{3,4,2} = [];

`cell2mat`

| `cell2struct`

| `cell2table`

| `iscell`

| `mat2cell`

| `num2cell`

| `struct2cell`

| `table2cell`