table
Writes the values of table object t to file, which is an Excel-compatible file. writetable is available only on Windows systems where Microsoft Excel is installed.
Syntax
t = table(var1, var2, ...)
Inputs
- t
- A table object.
- 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.
Outputs
- R
- A value of 1 indicates success and 0 indicates failure.
Examples
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
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
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
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
t = table({'A',1,2; 'B',3,4; 'C',5,6})
'A' 1 2
'B' 3 4
'C' 5 6