Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

Delete Data from a Cell Array

This example shows how to remove data from individual cells, and how to delete entire cells from a cell array. To run the code in this example, create a 3-by-3 cell array:

C = {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} = []

This code returns

C = 
    [1]    [2]    [3]
    [4]     []    [6]
    [7]    [8]    [9]

Delete sets of cells using standard array indexing with smooth parentheses, (). For example, this command

C(2,:) = []

removes the second row of C:

C = 
    [1]    [2]    [3]
    [7]    [8]    [9]

For related examples, see:

Was this topic helpful?