Main Content

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

Use one of these procedures:

Alternatively, if you have a test file that calls your entry-point function with example inputs, you can determine the input types by using coder.getArgTypes.

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:

  1. Define a table. For example:

    T = table(A,B,C,'VariableNames',vnames);

  2. Create a type from T.

    t = coder.typeof(T);
    

  3. Pass the type to fiaccel by using the -args option.

    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. Use coder.typeof (MATLAB Coder) or pass table as a string scalar to coder.newtype (MATLAB Coder).

The coder type object displays a succinct description of the object properties while excluding internal state values. Nonconstant properties display their type and size, while constant properties display only their values. For example:

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 cell

If your workflow requires the legacy representation of coder type objects, use the getCoderType function on the variable that has the new representation of your class or object. See Legacy Representation of Coder Type Objects (MATLAB Coder).

Resize Object Properties by Using coder.resize

You can resize most objects by using coder.resize (MATLAB Coder). You can resize objects, its properties and create arrays within the properties.

For a table coder object, you can resize the object properties:

A = [1 2 3]';
B = [4 5 6]';
C = [7 8 9]';
t = table(A,B,C);
tType = coder.typeof(t) 
tType.Description = coder.resize(tType.Description,[1 12],[0 1])

This code resizes the Description property to be a 1x:12 char property which has an upper bound of 12.

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 cell

You can also resize the object by using coder.resize. See Edit and Represent Coder Type Objects and Properties (MATLAB Coder).

See Also

| (MATLAB Coder) | (MATLAB Coder)

Related Topics