Main Content

Timetable Limitations for Code Generation

When you create timetables in MATLAB® code that you intend for code generation, you must create them by using the array2timetable, table2timetable, or timetable functions. For more information, see Timetables.

For timetables, code generation has these limitations:

  • The name of the first dimension of a timetable is 'Time' and cannot be changed. The name of the first dimension is also the name of the vector of row times, which you can refer to using dot notation.

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

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

  • Timetable variable names do not have to be valid MATLAB identifiers. The names must be composed of ASCII characters, but can include any ASCII characters (such as commas, dashes, and space characters).

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

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

  • To create a regular timetable when specifying the 'SampleRate', 'StartTime', or 'TimeStep' name-value pair arguments, 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.

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

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

  • To pass timetable indices 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 you index into a timetable by using duration values, or an object produced by the timerange or withtol functions, then the output is nonconstant with a variable number of rows.

  • If you index into a regular timetable by using duration values, or an object produced by the timerange or withtol functions, then the output is considered to be irregular.

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

  • 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
    
  • When you preallocate a timetable, you can specify only the following data types by using the 'VariableTypes' name-value pair argument.

    Data Type Name

    Initial Value in Each Element

    'double''single'

    Double- or single-precision 0

    'doublenan', 'doubleNaN''singlenan', 'singleNaN'

    Double- or single-precision NaN

    'int8''int16''int32''int64'

    Signed 8-, 16-, 32-, or 64-bit integer 0

    'uint8''uint16''uint32''uint64'

    Unsigned 8-, 16-, 32-, or 64-bit integer 0

    'logical'

    0 (false)

    'datetime'

    NaT datetime value

    'duration'

    0 seconds, as a duration value

    'cellstr'

    {''} (cell with 0-by-0 character array)

    If you specify 'char' as a data type, then timetable preallocates the corresponding variable as a cell array of character vectors, not as a character array. The best practice is to avoid creating timetable variables that are character arrays.

  • 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.

  • 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.

  • 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.

  • The set membership functions intersect, setdiff, setxor, and union support unsorted timetables in all cases. You do not have to specify the 'stable' option.

  • When using the convertvars function:

    • Function handles are not supported.

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

    • You cannot specify dataType as 'char'.

  • When using the movevars function, the input argument vars cannot contain duplicate variable names.

  • When using the isregular function:

    • 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'.

  • When using the retime or synchronize functions:

    • The row times of the output timetable are always 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.

  • When using the timerange function, the input argument unitOfTime is not supported.

Limitations that apply to classes also apply to timetables. For more information, see MATLAB Classes Definition for Code Generation.

See Also

| |

Related Topics