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 character vectors of different lengths, or mixes of strings 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 if 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 strings in array
strsplitSplit string or character vector at specified delimiter
struct2cellConvert structure to cell array
table2cellConvert table to 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.

Create Cell Array

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

Access Data in Cell Array

Read and write data from and to a cell array.

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.

Cell vs. Structure 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.