array2timetable

Converts an array into a timetable with given row times.

Category: Language Fundamentals > Data Types

Syntax

TT = array2timetable(A, 'RowTimes', t)

Builds a timetable with one row per row of A and times from the datetime or duration vector t.

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

Also names the variables.

TT = array2timetable(A, 'SampleRate', fs)

Generates evenly spaced times from a sample rate in hertz.

Description

This is how a plain matrix of measurements becomes time-indexed data. Row times are required unless a sample rate or time step is given. The result supports retime, synchronize and time-based indexing.

Input arguments

A
2-D array; each column becomes a variable.
'RowTimes'
datetime or duration vector with one entry per row, in increasing order.
'SampleRate'
Sampling rate in hertz, as an alternative to RowTimes.

Output arguments

TT
A timetable.

Example

Matrix with second-based times

A = [1 2; 3 4];
TT = array2timetable(A, 'RowTimes', seconds([1; 2]), 'VariableNames', {'a', 'b'})
Output
TT = 2×2 timetable

    Time     a    b
    _____    _    _

    1 sec    1    2
    2 sec    3    4

See also

timetable array2table retime seconds table2timetable