table

Methods

Method Reference: table.table2cell

table: C = table2cell (tbl)

Converts a table to a cell array.

C = table2cell (tbl) returns a cell array C of the same size as tbl, in which each cell holds one row of one variable, in the variable’s own type. A multicolumn variable gives a row in each cell, a char matrix one row of text, and a nested table a table of one row. A cell variable of one column gives the contents of its cells. The row names and every other property of tbl are left out.

Source Code: table

table2cell unpacks a table into a cell array with one cell per element, preserving heterogeneous variable types that table2array could not merge.

 LastName = {'Sanchez'; 'Johnson'; 'Li'};
 Age = [38; 43; 38];
 Smoker = logical ([1; 0; 1]);
 T = table (LastName, Age, Smoker)
T =
  3x3 table

     LastName      Age    Smoker    
    ___________    ___    ______    

    {'Sanchez'}     38    true      
    {'Johnson'}     43    false     
    {'Li'     }     38    true
 C = table2cell (T)
C =
  3x3 cell array

    {'Sanchez'}    {[38]}    {[1]}    
    {'Johnson'}    {[43]}    {[0]}    
    {'Li'     }    {[38]}    {[1]}

Each column of the cell array corresponds to one table variable, so the result is independent of the original variable types.

 class (C)
ans = cell