Cell Arrays

Arrays that can contain data of varying types and sizes

A cell array is a data type with indexed data containers calledcells, 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, 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 if 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 strings in array
strsplit 分割字符串或生产er vector at specified delimiter
struct2cell Convert structure to cell array
table2cell Convert table to cell array

Topics

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 thecellfunction.

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.