%% Merge Frame Data
% Merge two overlapping frame tables.
% Create table1, a 4-by-3 table that contains values for variable Var1 in four successive 5-second frames.

table1 = table(seconds(0:5:15)', seconds(5:5:20)', [3;4;5;6], ...
    'VariableNames', ["TimeStart", "TimeEnd", "Var1"])

% Create table2, also a 4-by-3 table, that overlaps the frames in table1. table2 contains the values for Var2.

table2 = table(seconds(5:5:20)', seconds(10:5:25)', [1;2;3;4], ...
    'VariableNames', ["TimeStart", "TimeEnd", "Var2"])

% Merge the two tables using "TimeStart" and "TimeEnd" as the merge keys.

table12 = joindata(table1, table2, 'Keys', ["TimeStart", "TimeEnd"])

% table12 is a 5-by-4 table that contains the values for Var1 and Var2 for each frame. Missing values are represented by NaN.
% Copyright 2020 The MathWorks, Inc.