Documentation

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, seeAccess Data in Cell Arrayor watchIntroducing Structures and Cell Arrays.

Functions

cell Cell array
cell2mat Convert cell array to ordinary array of the underlying data type
cell2struct Convert cell array to structure array
cell2table Convert cell array to table
celldisp Display cell array contents
cellfun Apply function to each cell in cell array
cellplot Graphically display structure of cell array
cellstr Convert to cell array of character vectors
iscell Determine whether input is cell array
iscellstr Determine if input is cell array of character vectors
mat2cell Convert array to cell array whose cells contain subarrays
num2cell Convert array to cell array with consistently sized cells
strjoin Join text in array
strsplit Split string at specified delimiter
struct2cell Convert structure to cell array
table2cell Convert table to cell array

Examples and How To

Create Cell Array

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

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.

Concepts

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.