Main Content

Cell Arrays

Arrays that can contain data of varying types and sizes

一个细胞与索引数据控制数组是一种数据类型ainers called cells, where each cell can contain any type of data. For instance,

c = {42, rand(5),"abcd"}
c = 1×3 cell array {[42]} {5×5 double} {["abcd"]}

To access the contents of a cell, enclose indices in curly braces, such asc{1}to return42andc{3}to return"abcd". For more information, seeAccess Data in Cell Array.

Cell arrays are useful for nontabular data that you want to access by numeric index. If you have tabular data, such as data from a spreadsheet, usetableortimetableinstead. If your data is text only, usestring.

Functions

expand all

cell Cell array

From Cell

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

To Cell

cellstr Convert to 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
struct2cell Convert structure to cell array
table2cell Convert table to cell array

Determine Type

iscell Determine if input is cell array
iscellstr Determine if input is cell array of character vectors
celldisp Display cell array contents
cellfun Apply function to each cell in cell array
cellplot Graphically display structure of cell array

Topics

Related Information