Cell Arrays
A cell array is a data type with indexed data containers called cells, where each cell can contain any type of data. For example:
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 as
c{1}
to return 42
and
c{3}
to return "abcd"
. For more
information, see Access 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,
use table
or timetable
instead. If your data
is text only, use string
.
Functions
Topics
- Access Data in Cell Array
Read and write data from and to a cell array.
- Create Cell Array
Create a cell array by using the
{}
operator or thecell
function. - Add or Delete Cells in Cell Array
Expand, concatenate, or remove data from a cell array.
- Preallocate Memory for Cell Array
Initialize and allocate memory for a cell array.