create a table from variables
t = table(var1, ..., varN) t = table(m) t = table(st) t = table(..., Name, Value)
vector or matrix with the same number of rows.
Each var can be different type: double, boolean, string, datetime or duration
double, boolean, string, datetime or duration matrix
structure
'VariableNames': matrix of strings that contains the name of each column of t
. Default value: ["Var1", ..., "VarN"]
'RowNames': indicator for reading the first column as row names
table object.
table is a data type used to store heterogeneous data. Each column of the table represents a variable, named VarN (N: column number) by default. Each variable in a table can have different data type. They must all have the same number of rows. Variable names are unique.
Regarding the extraction and insertion of data, a table is like a matrix: t(i,j) where i and j are indices. In addition to indices, it is possible to use the names of variables and rows to access the data: t.Var1 or t("Var1") where "Var1" is a variable name; t("Row1", "Var1") where "Row1" is a row name and "Var1" is a variable name. It is also possible to mix indices and variable name or row name: t(1,["Var1", "Var3"]) or t("Row1", [1 3]). The data being generally heterogeneous, it will be neccesary to use {} or table to insert data. If they are of the same type, the [] will preferred.
Use the readtable function to create a table from a file. If data contains a timestamp, use the timeseries function instead.
t = table(var1, ..., varN) creates a table from the data variables var1, ..., varN. The variables can be column vector or matrix with the same number of rows. Each var1, ..., varN can be different type.
t = table(m) creates a table from a matrix m. This syntaxe corresponds to t = matrix2table(st).
t = table(st) creates a table from a structure st. This syntaxe corresponds to t = struct2table(st).
t = table(..., Name, Value) can be used to specify the variable names or the row names.
'VariableNames': specify the name of variables. It is a row vector and the number of names must be equal the number of table variables. This data is stored in the properties of the table t in the 'VariableNames' field. For more information, see the Properties section below.
'RowNames': specify the name of rows. The number of names must be equal the number of table rows. This data is stored in the properties of the table t in the 'RowNames' field. For more information, see the Properties section below.
t contains several properties used to describe the index and the variables.
These properties can be accessed/modified by using Properties field of t.
Here is the list of available fields in t.Properties:
Description: contains the description of the table. Default value: "".
VariableNames: contains the variable names of the table. Default value: ["Var1", ..., "VarN"].
VariableDescriptions: contains the variable descriptions of the table. One description by variable. Default value: "".
VariableUnits: contains the variable units of the table. Default value: "".
RowNames: contains the row names of the table. Default value: ""
t = table(var1, ..., varN) with var1, ..., varN are column vectors
t = table(var1, ..., varN, "VariableNames", Value)
t = table(var1, ..., varN, "VariableNames", Value, "RowNames", Value)
Access to data in the table
Version | Description |
2024.0.0 | Introduction in Scilab. |