This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

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.

Cell Arrays

Arrays that can contain data of varying types and sizes

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 strings, 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, {}. For more information, see Access Data in Cell Array or watch Introducing Structures and Cell Arrays.


cellCell array
cell2matConvert cell array to ordinary array of the underlying data type
cell2structConvert cell array to structure array
cell2tableConvert cell array to table
celldispDisplay cell array contents
cellfunApply function to each cell in cell array
cellplotGraphically display structure of cell array
cellstrConvert to cell array of character vectors
iscellDetermine whether input is cell array
iscellstrDetermine if input is cell array of character vectors
mat2cellConvert array to cell array whose cells contain subarrays
num2cellConvert array to cell array with consistently sized cells
strjoinJoin text in array
strsplitSplit string at specified delimiter
struct2cellConvert structure to cell array
table2cellConvert table to cell array

Examples and How To

Create Cell Array

Create a cell array using the {} operator or the cell function.

Access Data in Cell Array

Read and write data to and from a cell array.

Add Cells to Cell Array

Add cells, columns, and rows, to a cell array.

Delete Data from Cell Array

Remove data from individual cells, and delete entire cells from a cell array.

Combine Cell Arrays

Combine cell arrays by concatenation or nesting.

Pass Contents of Cell Arrays to Functions

These examples show several ways to pass data from a cell array to a function that does not recognize cell arrays as inputs.

Preallocate Memory for Cell Array

Initialize and allocate memory for a cell array.


What Is a Cell Array?

A cell array is a data type with indexed data containers called cells. Each cell can contain any type of data.

Cell vs. Struct Arrays

This example compares cell and structure arrays, and shows how to store data in each type of array. Both cell and structure arrays allow you to store data of different types and sizes.

Combining Cell Arrays with Non-Cell Arrays

If you combine arrays in which one or more is a cell array, the resulting array is a cell array.

Multilevel Indexing to Access Parts of Cells

Access data in arrays stored within cells of cell arrays.