Convert table to timetable
converts the tableTT
= table2timetable(T
)T
到时间表。第一个DateTime或持续时间变量T
becomes the vector of row times ofTT
。The remaining variables ofT
become the variables ofTT
。
如果T
是一个M
-by-N
table without row names, thenTT
是一个M
-by-(N-1)
timetable.
如果T
是一个M
-by-N
table with row names, thentable2timetable
assigns the row names ofT
到一个变量TT
。结果是,TT
是一个M
-by-N
timetable.
有关创建和使用时间表的详细信息,请参阅时间表。
To create a timetable from data in a text or spreadsheet file, first use the可阅读
function to read the data to a table. Then convert the table to a timetable withtable2timetable
。
分配表变量TT
= table2timetable(T
,'RowTimes',timevarname.
)timevarname.
as the vector of row times of the output timetable.timevarname.
can be the name of any variable inT
that contains datetime or duration values. The remaining variables ofT
become the variables ofTT
。
在某些情况下,您可以打电话table2timetable
使用语法指定行时间之间的常规时间步长table2timetable
returns an irregular timetable. This result occurs when you specify the time step using a calendar unit of time and there is a row time that introduces an irregular step. For example, if you create a timetable with a time step of one calendar month, starting on January 31, 2019, then it is irregular with respect to months.
stime = datetime(2019,1,31); tstep = calmonths(1); T = table([1:3]'); TT = table2timetable(T,'TimeStep',tstep,'StartTime',stime)
TT = 3×1 timetable Time Var1 ___________ ____ 31-Jan-2019 1 28-Feb-2019 2 31-Mar-2019 3
还有其他情况,其中违规是由于夏令时(DST)的偏移或闰秒的行时间。此表指定了可能意外地产生不规则时间表的行时间值和时间步骤。
Row Time Value |
Time Step |
---|---|
开始时间指定为本月的第29,30或第31天。 |
Number of calendar months or quarters. |
开始时间指明为2月29日。 |
Number of calendar years. |
任何行时间在上午1点到下午2点到2:00。在一天中从DST转移到标准时间(当行时间指定为时区观察DST时的日期时间值时)。 | 日历日或月数。 |
闰秒的任何行时间(当行时间指定为时区的日期时间值时 |
在任何日历单元(天,周,月,季度或年份)中指定的时间步骤。 |