table2timetable
Convert table to timetable
Syntax
Description
converts the input table to a timetable. The first datetime or duration variable in
TT = table2timetable(T)T becomes the vector of row times of TT.
The remaining variables of T become the variables of
TT.
If
Tis anM-by-Ntable without row names, thenTTis anM-by-(N-1)timetable.If
Tis anM-by-Ntable with row names, thentable2timetableassigns the row names ofTto a variable ofTT. As a result,TTis anM-by-Ntimetable.
For more information on creating and using timetables, see Timetables.
To create a timetable from data in a text or spreadsheet file, use the readtimetable function.
assigns the table variable TT = table2timetable(T,'RowTimes',timeVarName)timeVarName as the vector of row times
of the output timetable. timeVarName can be the name or index of
any variable in T that contains datetime or duration values. The
remaining variables of T become the variables of
TT.
Examples
Input Arguments
Output Arguments
Tips
In certain cases, you can call
table2timetablewith a syntax that specifies a regular time step between row times, and yettable2timetablereturns 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 3There are other cases where irregularities are due to shifts from Daylight Saving Time (DST) or to
datetimevalues that are leap seconds. This table specifies the dates, times, and time steps that can produce irregular results unexpectedly.Row Time Value
Time Step
Start time specified as the 29th, 30th, or 31st day of the month.
Number of calendar months or quarters.
Start time specified as February 29.
Number of calendar years.
Any datetimevalue occurring between 1:00 a.m. and 2:00 a.m. on a day shifting from DST to standard time (when such values have a time zone that observes DST).Number of calendar days or months. Any
datetimevalue that is a leap second (when the time zone for such values is theUTCLeapSecondstime zone). For the list of leap seconds, seeleapseconds.Time step specified in any calendar unit (days, weeks, months, quarters, or years).