Main Content

Timetable Limitations for Code Generation

If you create timetables, modify them, or use timetable functions in MATLAB® code that you intend for code generation, then code generation has limitations described in the next sections. Limitations that apply to classes also apply to timetables. For more information on class limitations, see MATLAB Classes Definition for Code Generation.

Creating Timetables Limitations

If your MATLAB code creates timetables, then code generation has these limitations.

Inputs for Timetable Creation

Limitations

Any inputs

  • The name of the first dimension of a timetable is 'Time' unless you specify it by using the 'DimensionNames' name-value argument.

    The name of the first dimension is also the name of the vector of row times, which you can refer to by using dot notation.

  • To create a regular timetable when the 'SampleRate', 'StartTime', or 'TimeStep' name-value arguments are passed in by an entry point function, first use the coder.Constant function to make the values constant. If you do not make them constant, then the row times are considered to be irregular.

  • If you create a regular timetable, and you attempt to set irregular row times, then an error is produced.

  • If you create an irregular timetable, then it remains irregular even if you set its sample rate or time step.

  • Timetable variable names do not have to be valid MATLAB identifiers. The names must be composed of ASCII characters, which can include commas, dashes, and space characters.

Timetable created from input arrays

  • You must specify variables names by using the 'VariableNames' name-value argument when creating timetables from input arrays by using the timetable or array2timetable functions.

Timetable created with preallocated variables

  • You do not have to specify the 'VariableNames' argument when you preallocate a timetable by using the timetable function and the 'Size' name-value argument.

  • You can specify only the following data types by using the 'VariableTypes' name-value argument:

    • 'double'

    • 'single'

    • 'doublenan' or 'doubleNaN'

    • 'singlenan' or 'singleNaN'

    • 'int8''int16''int32', or 'int64'

    • 'uint8''uint16''uint32', or 'uint64'

    • 'logical'

    • 'datetime'

    • 'duration'

    • 'cellstr'

    • 'char'

Modifying Timetables Limitations

If your MATLAB code modifies data in a timetable, its row times, or its properties, then code generation has these limitations.

Timetable Operation or Property

Limitations

VariableNames, DimensionNames, or UserData properties

  • After you create a timetable, you cannot change the VariableNames, DimensionNames, or UserData properties.

    When you create a timetable, you can specify the 'VariableNames', 'DimensionNames', and 'RowTimes' input arguments to set the properties having those names.

VariableTypes property

  • After you create a timetable, you cannot access the VariableTypes property.

  • When you preallocate a timetable during its creation, you can specify the 'VariableTypes' input argument.

Timetable indices as input arguments to generated code

  • To pass timetable indices that specify variables into generated code as input arguments, first use the coder.Constant function to make the indices into the second dimension of the timetable constant. If indices into the second dimension are not constant, then indexing into variables produces an error.

  • If a timetable has row times that are duration values, and you index into it by using either duration values or an object produced by the timerange or withtol functions, then the output is nonconstant with a variable number of rows.

  • If a regular timetable has row times that are duration values, and you index into it by using either duration values or an object produced by the timerange or withtol functions, then the output is considered to be irregular.

Custom metadata

  • You cannot add custom metadata to a timetable. The addprop and rmprop functions are not supported.

Assignments that change size of timetable

  • You cannot change the size of a timetable by assignments. For example, this call to add a new row produces an error.

    function TT = foo() %#codegen
        TT = timetable((1:3)',(1:3)',...
        'RowTimes',seconds([0,5,10]),...
        'VariableNames',{'Var1','Var2'});
        TT{4,:} = [5,5];
    end
    

    Deleting a row or a variable by assignment also produces an error.

  • You cannot add a new row by using a new row time in an assignment. For example, this call to add a new row by using a new row time instead of a numeric index does not produce an error, but also does not add the new row.

    function TT = foo() %#codegen
        TT = timetable((1:3)',(1:3)',...
        'RowTimes',seconds([0,5,10]),...
        'VariableNames',{'Var1','Var2'});
        TT{seconds(15),:} = [5,5];
    end
    

Vertical concatenation

  • When you vertically concatenate timetables, they must have the same variable names in the same order. In MATLAB, the variable names must be the same but can be in different orders in the timetables.

Horizontal concatenation

  • When you horizontally concatenate timetables, they must have the same row times in the same order. In MATLAB, the row times must be the same but can be in different orders in the timetables.

Timetable variables that are N-D cell arrays

  • If two timetables have variables that are N-D cell arrays, then you cannot vertically concatenate the timetables.

  • You cannot use curly braces to extract data from multiple timetable variables that are N-D cell arrays because this operation is horizontal concatenation.

Using Timetable Functions Limitations

If your MATLAB code uses the functions listed in the table, then code generation has these limitations.

Function

Limitations

convertvars

  • Function handles are not supported.

  • The second and third input arguments (vars and dataType) must be constant.

  • You cannot specify dataType as 'cell', 'cellstr', or 'char'.

innerjoin

  • In general, the input timetables cannot have any nonkey variables with the same names. However, you can join subsets of the input timetables if you specify the 'LeftVariables' and 'RightVariables' name-value arguments. Specify these arguments so that no variable name appears in both 'LeftVariables' and 'RightVariables'.

  • The values of these name-value arguments must be constant:

    • 'Keys'

    • 'LeftKeys'

    • 'RightKeys'

    • 'LeftVariables'

    • 'RightVariables'

  • Nested timetables are not supported.

intersect

setdiff

setxor

union

  • These functions support unsorted timetables in all cases. You do not have to specify the 'stable' option.

isregular

  • Use coder.Constant to make the input argument timeComponent constant.

  • The input argument timeComponent cannot be a calendar unit. If you specify it, then its value must be 'time'.

issortedrows

  • The input argument vars must be constant.

  • If any timetable variables have multiple columns, then those variables must have fixed widths.

join

  • In general, input timetables cannot have nonkey variables with the same names. However, you can join subsets of the input timetables if you specify the name-value arguments:

    • 'KeepOneCopy', where you list variables to take from the left input timetable only.

    • 'LeftVariables' and 'RightVariables', where you list variables to take from either the left input timetable or the right input timetable, but not both.

  • The values of these name-value arguments must be constant:

    • 'Keys'

    • 'LeftKeys'

    • 'RightKeys'

    • 'LeftVariables'

    • 'RightVariables'

    • 'KeepOneCopy'

  • Nested timetables are not supported.

movevars

  • The input argument vars cannot contain duplicate variable names.

outerjoin

  • Input timetables cannot have key variables with the same names unless the value of 'MergeKeys' is true (logical 1).

  • In general, the input timetables cannot have any nonkey variables with the same names. However, you can join subsets of the input timetables if you specify the 'LeftVariables' and 'RightVariables' name-value arguments. Specify these arguments so that no variable name appears in both 'LeftVariables' and 'RightVariables'.

  • The values of these name-value arguments must be constant:

    • 'Keys'

    • 'LeftKeys'

    • 'RightKeys'

    • 'MergeKeys'

    • 'LeftVariables'

    • 'RightVariables'

    • 'Type'

  • Nested timetables are not supported.

retime

synchronize

  • The row times of the output timetable are considered to be irregular, even when synchronized to row times that have a regular time step.

  • The 'makima' interpolation method is not supported.

  • If the VariableContinuity properties of the input timetables are not constant, then this function ignores them.

  • The 'weekly', 'monthly', and 'quarterly' time steps are not supported.

    • If the input timetables have row times that are datetime values, then the 'daily' and 'yearly' time steps also are not supported.

sortrows

  • The input argument vars must be constant.

  • If tblA has a variable that is a cell array of character vectors with multiple columns, then you cannot sort the timetable using the values in that variable.

splitvars

  • The value of the 'NewVariableNames' name-value argument must be constant.

  • The variables that are split cannot have a variable number of columns.

stack

  • The second input argument, vars, must be constant.

  • The values of the 'ConstantVariables', 'NewDataVariableName', and 'IndexVariableName' name-value arguments must be constant.

timerange

  • The input argument datetimeUnit is not supported.

  • Event filters are not supported.

unstack

  • The 'NewDataVariableNames' name-value argument must be specified. Its value must be constant.

  • The vars and ivars input arguments (data variables and indicator variables) must be constant.

  • If you specify grouping variables and constant variables, then they must be constant.

  • If you specify an aggregation function, then it must be constant.

  • If the input is a timetable with regular row times and you specify grouping variables that do not include the row times, then the output timetable might have irregular row times. Even though the intervals between output row times might look the same, the output timetable considers the vector of row times to be irregular.

  • If a variable of the input timetable is a cell array of character vectors, then unstack fills empty cells in the corresponding output variable with 1-by-0 character arrays in the generated code. In MATLAB, unstack fills such gaps with 0-by-0 character arrays.

  • The unstack function does not support code generation when the input timetable has a variable that is a heterogeneous cell array that cannot be converted to a homogeneous cell array.

    • If the input has a variable that is a homogeneous cell array, or that can be converted to one, then the 'AggregationFunction' name-value argument must be specified. The default value of 'AggregationFunction' is 'unique'. But the unique function does not support cell arrays.

varfun

  • The function handle input, func, must be constant.

  • While function handles can be inputs to varfun itself, they cannot be inputs to your entry point functions. Specify func within the code meant for code generation. For more information, see Function Handle Limitations for Code Generation.

  • The values for allname-value arguments must be constant.

  • The 'ErrorHandler' name-value argument is not supported for code generation.

  • Variable-size input arguments are not supported.

  • If you specify 'GroupingVariables', then the output is always an irregular timetable.

  • Grouping variables cannot have duplicate values in generated code.

  • You cannot specify the value of 'OutputFormat' as 'cell' if you specify the 'GroupingVariables' name-value arguments and the function returns a different data type for each variable specified by 'InputVariables'.

  • If you specify groups and the number of groups is not known at compile-time, and that number turns out to be zero, then empty double variables in the output might have sizes of 1-by-0 in generated code. In MATLAB, such variables have sizes of 0-by-0.

withtol

  • Event filters are not supported.

See Also

| |

Related Topics