Merge two frame tables using an outer join
joindata is a function used in code generated by Diagnostic Feature
merges two tables using an outer join with the first two columns as the primary keys to
merge. In general, an outer join combines table rows where the key variables have matching
values, while also retaining rows where key variables from one input table have no matches
in the other input table (see
table12 = joindata(
joins two frame tables. The first two columns of both frame tables contain the segment start
and segment end points. The other columns in the tables contain data associated with the
frame. The data column names must be unique, that is, data columns in
table2 must not have the same name as the data columns in
Code that is generated by Diagnostic Feature
joindata when performing frame-based ensemble
statistics processing. In the code,
table1 contains existing frame data
table2 contains newly computed frame results.
uses the columns with the names specified in
table12 = joindata(
keys as the primary keys
for the merge. For example,
'Keys',["TimeStart","TimeEnd"] specifies that
joindata use the columns named
"TimeEnd" rather than automatically using the first two columns for
Merge Frame Data
Merge two overlapping frame tables.
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"])
table1=4×3 table TimeStart TimeEnd Var1 _________ _______ ____ 0 sec 5 sec 3 5 sec 10 sec 4 10 sec 15 sec 5 15 sec 20 sec 6
table2, also a 4-by-3 table, that overlaps the frames in
table2 contains the values for
table2 = table(seconds(5:5:20)', seconds(10:5:25)', [1;2;3;4], ... 'VariableNames', ["TimeStart", "TimeEnd", "Var2"])
table2=4×3 table TimeStart TimeEnd Var2 _________ _______ ____ 5 sec 10 sec 1 10 sec 15 sec 2 15 sec 20 sec 3 20 sec 25 sec 4
Merge the two tables using "
TimeStart" and "
TimeEnd" as the merge keys.
table12 = joindata(table1, table2, 'Keys', ["TimeStart", "TimeEnd"])
table12=5×4 table TimeStart TimeEnd Var1 Var2 _________ _______ ____ ____ 0 sec 5 sec 3 NaN 5 sec 10 sec 4 1 10 sec 15 sec 5 2 15 sec 20 sec 6 3 20 sec 25 sec NaN 4
table12 is a 5-by-4 table that contains the values for
Var2 for each frame. Missing values are represented by
table1 — First frame table to merge
First frame table to merge, specified as a table with the first two columns representing the segment start and stop points, and the remaining columns containing the corresponding data.
table2 — Second frame table to merge
Second frame table to merge, specified as a table with the first two columns
representing the segment start and stop point, and the remaining columns containing the
corresponding data. Data column names must not match any data column names in
keys — Primary keys
string array | cell array
Primary keys for table merge, specified as the comma-separated pair containing
'Keys' and either a string array with two strings or a cell of two
table12 — Merged frame data
Merged frame data, returned as a table.