Delete Data from Cell Array
This example shows how to remove data from individual cells, and how to delete entire
cells from a cell array.
Create a 3-by-3 cell array
C = {1, 2, 3; 4, 5, 6; 7, 8, 9}
C = 3x3 cell array
{[1]} {[2]} {[3]}
{[4]} {[5]} {[6]}
{[7]} {[8]} {[9]}
Delete the contents of a particular cell by assigning an empty array to the cell, using curly
braces for content indexing, {}.
C{2,2} = []
C = 3x3 cell array
{[1]} {[ 2]} {[3]}
{[4]} {0x0 double} {[6]}
{[7]} {[ 8]} {[9]}
Delete sets of cells using standard array indexing with smooth parentheses, (). For
example, remove the second row of C.
C(2,:) = []
C = 2x3 cell array
{[1]} {[2]} {[3]}
{[7]} {[8]} {[9]}
See Also
Related Examples
- “Add Cells to Cell Array” on page 12-8
12 Cell Arrays