timetable

Creates a table whose rows are labeled with times.

Category: Language Fundamentals > Data Types

Syntax

TT = timetable(rowTimes, var1, var2, ...)

Creates a timetable from a time vector and data variables of the same height.

TT = timetable(___, 'VariableNames', names)

Names the data variables.

Description

A timetable is a table that always has the times as its first column, which allows time-aware operations: selecting with timerange, aligning with synchronize, resampling with retime, and plotting against time. Data variables are read like table variables, TT.x, and the times with TT.Time.

Indexing a row gives another timetable; indexing a variable with a dot gives the raw column.

Input arguments

rowTimes
datetime or duration vector, one value per row.
var1, var2, ...
Data arrays with as many rows as rowTimes.
'VariableNames'
Names of the data variables.

Output arguments

TT
Timetable. The row times are in TT.Time (or the name you gave them).

Example

Build and read a timetable

TT = timetable(seconds([0;1;2]), [5;6;7], 'VariableNames', {'x'})
TT.x
TT.Time
Output
TT = 3×1 timetable

    Time     x
    _____    _

    0 sec    5
    1 sec    6
    2 sec    7
ans = 3×1

     5
     6
     7
ans = 3×1 duration array

   0 sec
   1 sec
   2 sec

See also

table timerange synchronize retime table2timetable timeseries