synchronize

Aligns several timetables onto a common time vector.

Category: Language Fundamentals > Data Types

Syntax

TT = synchronize(TT1, TT2)

Combines two timetables over the union of their row times, filling gaps with missing values.

TT = synchronize(TT1, TT2, newTimes)

Aligns onto a time basis: 'union', 'intersection', 'first', 'last', or an explicit time vector.

Description

synchronize is the tool to put signals recorded at different instants into one table. With 'union' every time that appears in any input is kept and unknown values are NaN; with 'intersection' only times present in all inputs survive; 'first' and 'last' use the times of the first or last input.

A fourth argument naming a method, such as 'fillwithmissing', controls how values at times missing from an input are obtained.

Input arguments

TT1, TT2, ...
Timetables with distinct variable names.
newTimes
The set of row times for the output.

Output arguments

TT
Timetable whose variables are those of all inputs side by side.

Example

Union and intersection

t1 = timetable(seconds([1;2;3]), [10;20;30], 'VariableNames', {'A'});
t2 = timetable(seconds([2;3;4]), [5;6;7], 'VariableNames', {'B'});
synchronize(t1, t2)
synchronize(t1, t2, 'intersection')
Output
ans = 4×2 timetable

    Time      A      B 
    _____    ___    ___

    1 sec     10    NaN
    2 sec     20      5
    3 sec     30      6
    4 sec    NaN      7
ans = 2×2 timetable

    Time     A     B
    _____    __    _

    2 sec    20    5
    3 sec    30    6

See also

timetable retime join innerjoin outerjoin