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 thearray2timetable,table2timetable, ortimetablefunctions. For more information, seeTimetables.

这些limitati时间表,代码生成ons:

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

    You do not have to specify the'VariableNames'argument when you preallocate a timetable by using thetimetablefunction 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 theVariableNames,DimensionNames, orUserDataproperties.

    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 thecoder.Constantfunction 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 thecoder.Constantfunction 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 usingdurationvalues, or an object produced by thetimerangeorwithtolfunctions, then the output is nonconstant with a variable number of rows.

  • If you index into a regular timetable by usingdurationvalues, or an object produced by thetimerangeorwithtolfunctions, then the output is considered to be irregular.

  • You cannot add custom metadata to a timetable. Theaddpropandrmpropfunctions 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.

    functionTT = foo()%#codegenTT = 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.

  • 您不能添加一个新行时间我通过使用一个新行n 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.

    functionTT = foo()%#codegenTT = 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-precision0

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

    Double- or single-precisionNaN

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

    Signed 8-, 16-, 32-, or 64-bit integer0

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

    Unsigned 8-, 16-, 32-, or 64-bit integer0

    'logical'

    0(false)

    'datetime'

    NaTdatetime value

    'duration'

    0seconds, as a duration value

    'cellstr'

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

    If you specify'char'as a data type, thentimetablepreallocates 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 functionsintersect,setdiff,setxor, andunionsupport unsorted timetables in all cases. You do not have to specify the'stable'option.

  • When using theconvertvarsfunction:

    • Function handles are not supported.

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

    • You cannot specifydataTypeas'char'.

  • When using themovevarsfunction, the input argumentvarscannot contain duplicate variable names.

  • When using theisregularfunction:

    • Usecoder.Constantto make the input argumenttimeComponentconstant.

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

  • When using theretimeorsynchronizefunctions:

    • 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 theVariableContinuityproperties 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 aredatetimevalues, then the'daily'and'yearly'time steps also are not supported.

  • When using thetimerangefunction, the input argumentunitOfTimeis not supported.

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

See Also

||

Related Topics