主要内容

时间表的代码生成

时间表数据类型是一种数据类型适合表格数据with time-stamped rows. Like tables, timetables consist of rows and column-oriented variables. Each variable in a timetable can have a different data type and a different size with one restriction: each variable must have the same number of rows.

行时间of a timetable are time values that label the rows. You can index into a timetable by row time and variable. To index into a timetable, use smooth parentheses()返回款项或卷曲牙套{}提取内容。您可以将变量和行时间的向量引用。有关更多信息,请参阅时间表

当您使用代码生成的时间表时,请遵守这些限制。

定义代码生成的时间表

对于代码生成,请使用时间表功能。例如,假设输入参数到您的matlab®功能是三个数组,具有相同数量的行(一个,,,,b, 和C), 一个约会时间or期间包含行时间的向量(d),以及具有可变名称的单元格数组(vnames)。您可以创建一个包含这些数组作为时间表变量的时间表。

功能tt = foo(a,b,c,d,vnames)%#codegentt =表(a,b,c,“行时”,D,'variablenames',vnames);结尾

要将数组和表转换为时间表,请使用array2timetableandtable2timetable功能。例如,您可以转换输入m-经过-nmatrix to a timetable, where each column of the matrix becomes a variable in the timetable. Assign row times by using a期间向量。

功能tt = foo(a,d,vnames)%#codegentt = array2timetable(a,“行时”,D,'variablenames',vnames);结尾

For code generation, you must supply timetable variable names when you create a timetable. 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).

这行时间can have either the约会时间or期间数据类型。

一个llowed Operations on Timetables

对于代码生成,您仅限于此表中列出的时间表上的操作。

手术 例子 笔记

分配操作员:=

tt =时间表(a,b,c,“行时”,D,'variablenames',vnames);tt {:,1} = x;

代码生成不支持使用分配操作员万博1manbetx=至:

  • 删除变量或行。

  • 添加变量或一行。

索引操作

d =秒(1:10);tt =时间表(a,b,c,“行时”,D,'variablenames',vnames);TT(seconds(3:7),1:3);

代码生成支持按位置,可变时间或行万博1manbetx时间以及逻辑索引索引。另外,您可以使用使用该对象进行索引时间范围orwithtol功能。

代码生成支持:万博1manbetx

  • 使用平滑括号的时间表索引,()。

  • 内容用卷曲括号索引{}。

  • 点表示法以访问时间表变量。

级联

tt1 =时间表(a,b,c,“行时”,d1,'variablenames',vnames);tt2 =时间表(d,e,f,“行时”,d2,'variablenames',vnames);tt = [tt1;tt2];

代码生成支持时间表串联。万博1manbetx

  • 对于垂直串联,时间表必须具有以相同顺序具有相同名称的变量。

  • 对于水平串联,时间表必须具有相同数量的行。他们还必须以相同的顺序具有相同的行时间。

MATLAB支持时间表的工具箱函数万博1manbetx

对于代码生成,您可以使用这些MATLAB工具箱函数使用时间表:

Related Topics