table2timetable
Converts a table with a time variable into a timetable.
Category: Language Fundamentals > Data Types
Syntax
TT = table2timetable(T)
Uses the first datetime or duration variable of T as the row times.
Description
A timetable requires its row times to be a datetime or duration vector. table2timetable takes that vector from the table and removes it from the data columns, so the number of variables falls by one. The row times are shown under the original name when it is available.
The inverse is timetable2table.
Input arguments
T- Table whose first variable (or a chosen one) holds datetime or duration values.
Output arguments
TT- Timetable with the time variable moved to the row times; the other variables are kept.
Example
Duration column as row times
T = table(seconds([1;2;3]), [4;5;6], 'VariableNames', {'t','v'});
TT = table2timetable(T)
Output
TT = 3×1 timetable
t v
_____ _
1 sec 4
2 sec 5
3 sec 6