## 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 (MATLAB).

For timetables, code generation has these limitations:

• The row times must have the `duration` data type. Row times cannot have the `datetime` data type.

• The name of the first dimension of a timetable is always `'Time'`. 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 must be valid MATLAB identifiers. Variable names must start with a letter and can include only letters, digits, and underscores.

• 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 index into a timetable by using variables names, first use the `coder.Constant` function to make the timetable constant.

By default, timetables that you pass into generated code as input arguments are not constant. Even their variables and row times are not constant. If a timetable is not constant, then an indexing operation that uses variables produces an error. You can index into the variables of a timetable by using numeric or logical indices even if the timetable is not constant.

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

Limitations that apply to classes also apply to timetables. For more information, see MATLAB Classes Definition for Code Generation.
{"ft_lang_label":"__label__en","ft_lang_prob":0.7478961,"math_prob":0.94720095,"size":5135,"snap":"2020-24-2020-29","text_gpt3_token_len":1159,"char_repetition_ratio":0.16565971,"word_repetition_ratio":0.16256158,"special_character_ratio":0.21499513,"punctuation_ratio":0.13333334,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9586832,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-06-07T10:07:29Z\",\"WARC-Record-ID\":\"<urn:uuid:3b7deec7-8a47-4b2f-bece-4f59211d6c71>\",\"Content-Length\":\"72305\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:eca28bc8-9c4e-4f42-a55e-6129f4b6a3b8>\",\"WARC-Concurrent-To\":\"<urn:uuid:8e108d6b-3607-4a78-ae53-47f16a036e71>\",\"WARC-IP-Address\":\"23.66.56.59\",\"WARC-Target-URI\":\"https://se.mathworks.com/help/coder/ug/timetable-limitations-for-code-generation.html\",\"WARC-Payload-Digest\":\"sha1:MY72MHWY7XMMVVFW4LPRZVGZOGWQMWM6\",\"WARC-Block-Digest\":\"sha1:BVRN5KLSRXHFMJKIUX2IY3QGTHTOWFGV\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-24/CC-MAIN-2020-24_segments_1590348526471.98_warc_CC-MAIN-20200607075929-20200607105929-00392.warc.gz\"}"}