table

Creates a table object t.

Syntax

t = table(var1, var2, ...)

Inputs

t
A table object.
Type: table
varn
Data from the session (either a cell array or matrix) to be included in the table. The data must be one-dimensional. If a variable name is used to pass the data, that will be used as the heading for that column in the table. If varn is 'RowNames', the following data vector will be used as row identifiers for the table and listed first.
Type: string | struct

Outputs

R
A value of 1 indicates success and 0 indicates failure.
Type: integer

Examples

Create a table from data in the session:
Lake = {'Superior','Michigan','Huron','Erie','Ontario'};
Area = [31700, 22300, 23000, 9910, 7340];
Volume = [2900, 1180, 850, 116, 393];
t = table(Lake, Area, Volume)
Lake Area Volume
____ ____ ______
'Superior' 31700 2900
'Michigan' 22300 1180
'Huron' 23000 850
'Erie' 9910 116
'Ontario' 7340 393
Create a table from data in the session using row names:
Lake = {'Superior','Michigan','Huron','Erie','Ontario'};
Area = [31700, 22300, 23000, 9910, 7340];
Volume = [2900, 1180, 850, 116, 393];
t = table('RowNames', Lake, Area, Volume)
Area Volume
____ ______
Superior 31700 2900
Michigan 22300 1180
Huron 23000 850
Erie 9910 116
Ontario 7340 393
Create a table from data in the session using row names and extract a column:
Lake = {'Superior','Michigan','Huron','Erie','Ontario'};
Area = [31700, 22300, 23000, 9910, 7340];
Volume = [2900, 1180, 850, 116, 393];
t = table('RowNames', Lake, Area, Volume);
t.Area
ans = [Matrix] 1 x 5
31700  22300  23000  9910  7340
Create a table from data in the session and extract a single value:
Lake = {'Superior','Michigan','Huron','Erie','Ontario'};
Area = [31700, 22300, 23000, 9910, 7340];
Volume = [2900, 1180, 850, 116, 393];
t = table(Lake, Area, Volume);
t(1,1)
ans = Superior
Create a table from a cell array:
t = table({'A',1,2; 'B',3,4; 'C',5,6})
'A' 1 2
'B' 3 4
'C' 5 6