Define Table Inputs
You can define table inputs at the command line. Programmatic
specification of table input types by using preconditioning (assert
statements) is not supported.
Define Table Inputs at the Command Line
Define table inputs at the command line by providing an example input or by using a table type. You can also specify a constant table input.
Provide an Example Table Input
Use the -args
option:
T = table(A,B,C,'VariableNames',vnames); fiaccel myFunction -args {T}
Provide a Table Type
To provide a type for a table to fiaccel:
Define a table. For example:
T = table(A,B,C,'VariableNames',vnames);Create a type from
T.t = coder.typeof(T);
Pass the type to
fiaccelby using the-argsoption.fiaccel myFunction -args {t}
Provide a Constant Table Input
To specify that a table input is constant, use coder.Constant with the -args
option:
T = table(A,B,C,'VariableNames',vnames); fiaccel myFunction -args {coder.Constant(T)}
Representation of Tables
A coder type object for a table describes the object and its properties. Create a new
table type by using coder.typeof or coder.newtype.
The coder type object displays a succinct description of the object properties while
excluding internal state values. The command line interface displays the type and size of
nonconstant properties and the values of constant properties. For example, create a coder
table type with a size of 3-by-3.
A = [1 2 3]'; B = [4 5 6]'; C = [7 8 9]'; t = table(A,B,C); tType = coder.typeof(t)
The representation of variable t is stored in coder type object
tType.
tType =
matlab.coder.type.TableType
3x3 table
Data : 1x3 homogeneous cell
Description : 1x0 char
UserData : 0x0 double
DimensionNames : {'Row'} {'Variables'}
VariableNames : {'A'} {'B'} {'C'}
VariableDescriptions : 1x3 homogeneous cell
VariableUnits : 1x3 homogeneous cell
VariableContinuity : 1x3 matlab.internal.coder.tabular.Continuity
RowNames : 0x0 homogeneous cellIf necessary, you can obtain the legacy coder.ClassType
representation of a table coder type by using the method
getCoderType. For example, to view the underlying
coder.ClassType representation of the tType object,
use this
command:
tType.getCoderType
ans =
coder.ClassType
1×1 table
Properties :
data : 1×0 homogeneous cell
cell with no elements
metaDim : 1×1 matlab.internal.coder.tabular.private.metaDim
Properties :
labels : {'Row'} {'Variables'}
length : 1×1 double
rowDim : 1×1 matlab.internal.coder.tabular.private.rowNamesDim
Properties :
labels : 0×0 homogeneous cell
cell with no elements
length : 0
varDim : 1×1 matlab.internal.coder.tabular.private.varNamesDim
Properties :
descrs : 1×0 homogeneous cell
cell with no elements
units : 1×0 homogeneous cell
cell with no elements
continuity : 0×0 double
customProps : 1×1 struct with no fields
hasDescrs : 1×1 logical
hasUnits : 1×1 logical
hasContinuity : 1×1 logical
hasCustomProps : 1×1 logical
labels :
length : 1×1 double
arrayProps : 1×1 struct
Description: 1×0 char
UserData: 0×0 doubleObject Properties
You can edit the properties of coder table type objects. You can
assign scalar values to object properties. Values are implicitly converted to the
corresponding coder type values when they are assigned to coder type object properties. You
can resize objects themselves by using the coder.resize function or by editing object properties
directly.
Resize Object Properties by Using coder.resize
You can resize table objects and object properties by using
coder.resize. You can also create arrays within properties.
For example, create a coder table type with a size of 3-by-3. The
Description property has a size of
1-by-0.
A = [1 2 3]'; B = [4 5 6]'; C = [7 8 9]'; t = table(A,B,C); tType = coder.typeof(t)
tType =
matlab.coder.type.TableType
3x3 table
Data : 1x3 homogeneous cell
Description : 1x0 char
UserData : 0x0 double
DimensionNames : {'Row'} {'Variables'}
VariableNames : {'A'} {'B'} {'C'}
VariableDescriptions : 1x3 homogeneous cell
VariableUnits : 1x3 homogeneous cell
VariableContinuity : 1x3 matlab.internal.coder.tabular.Continuity
RowNames : 0x0 homogeneous cellUse coder.resize to make Description variable
length with an upper bound of
12.
tType.Description = coder.resize(tType.Description,[1 12],[0 1])
tType =
matlab.coder.type.TableType
3x3 table
Data : 1x3 homogeneous cell
Description : 1x:12 char
UserData : 0x0 double
DimensionNames : {'Row'} {'Variables'}
VariableNames : {'A'} {'B'} {'C'}
VariableDescriptions : 1x3 homogeneous cell
VariableUnits : 1x3 homogeneous cell
VariableContinuity : 1x3 matlab.internal.coder.tabular.Continuity
RowNames : 0x0 homogeneous cellResize Objects Directly
You can also resize certain type objects themselves by editing the object properties.
For example, to change the number of rows in the tType object, edit the
Size
property.
tType.Size = [10 3]
tType =
matlab.coder.type.TableType
10x3 table
Data : 1x3 homogeneous cell
Description : 1x:12 char
UserData : 0x0 double
DimensionNames : {'Row'} {'Variables'}
VariableNames : {'A'} {'B'} {'C'}
VariableDescriptions : 1x3 homogeneous cell
VariableUnits : 1x3 homogeneous cell
VariableContinuity : 1x3 matlab.internal.coder.tabular.Continuity
RowNames : 0x0 homogeneous cellYou can also make the number of rows variable size by using the
VarDims
property.
tType.VarDims = [true false]
tType =
matlab.coder.type.TableType
:10x3 table
Data : 1x3 homogeneous cell
Description : 1x:12 char
UserData : 0x0 double
DimensionNames : {'Row'} {'Variables'}
VariableNames : {'A'} {'B'} {'C'}
VariableDescriptions : 1x3 homogeneous cell
VariableUnits : 1x3 homogeneous cell
VariableContinuity : 1x3 matlab.internal.coder.tabular.Continuity
RowNames : 0x0 homogeneous cell
See Also
table | coder.Constant | coder.newtype | coder.typeof