Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

# table2cell

Convert table to cell array

## 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

expand all

### Convert Table to Cell Array

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

```T = table(['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 =

'M'    [38]    [1x2 double]
'M'    [43]    [1x2 double]
'F'    [38]    [1x2 double]
'F'    [40]    [1x2 double]
'F'    [49]    [1x2 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 =

'Gender'    'Age'    'BloodPressure'
'M'         [ 38]       [1x2 double]
'M'         [ 43]       [1x2 double]
'F'         [ 38]       [1x2 double]
'F'         [ 40]       [1x2 double]
'F'         [ 49]       [1x2 double]```

T.Properties.VariableNames is a cell array of strings.

## Input Arguments

expand all

### T — Input tabletable

Input table, specified as a table.

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