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.

table2cell

Convert table to cell array

Syntax

Description

example

C = table2cell(T) converts the table, T, to a cell array, C. Each variable in T becomes a column of cells in C.

Examples

collapse all

Create a table, T, with five rows and three variables.

T = table(categorical({'M';'M';'F';'F';'F'}),[38;43;38;40;49],...
    [124 93;109 77; 125 83; 117 75; 122 80],...
    'VariableNames',{'Gender' 'Age' 'BloodPressure'},...
    'RowNames',{'Smith' 'Johnson' 'Williams' 'Jones' 'Brown'})
T = 

                Gender    Age    BloodPressure
                ______    ___    _____________

    Smith       M         38     124     93   
    Johnson     M         43     109     77   
    Williams    F         38     125     83   
    Jones       F         40     117     75   
    Brown       F         49     122     80   

Convert T to a cell array.

C = table2cell(T)
C =

  5×3 cell array

    [M]    [38]    [1×2 double]
    [M]    [43]    [1×2 double]
    [F]    [38]    [1×2 double]
    [F]    [40]    [1×2 double]
    [F]    [49]    [1×2 double]

C is a 5-by-3 cell array.

Vertically concatenate the table property, T.Properties.VariableNames, with C to include column headings for the cell array.

[T.Properties.VariableNames;C]
ans =

  6×3 cell array

    'Gender'    'Age'    'BloodPressure'
    [M     ]    [ 38]    [1×2 double]
    [M     ]    [ 43]    [1×2 double]
    [F     ]    [ 38]    [1×2 double]
    [F     ]    [ 40]    [1×2 double]
    [F     ]    [ 49]    [1×2 double]

T.Properties.VariableNames is a cell array of character vectors.

Input Arguments

collapse all

Input table, specified as a table.

If T is an m-byn table, then C is an m-by-n cell array.

More About

collapse all

Tall Array Support

This function fully supports tall arrays. For more information, see Tall Arrays.

Introduced in R2013b

Was this topic helpful?