Combine two tables using key variables in the Live Editor
The Join Tables task lets you interactively combine two tables by performing joins or by concatenating the tables horizontally or vertically. The task automatically generates MATLAB® code for your live script.
Using this task, you can:
Perform joins, including inner and outer joins, on tables by specifying key variables—table variables whose matching values, or key values, determine which rows are merged into the output table.
Horizontally or vertically concatenate tables with the same number of rows or variables, respectively.
To add the Join Tables task to a live script in the MATLAB Editor:
On the Live Editor tab, select Task > Join Tables.
In a code block in the script, type a relevant keyword, such as
join
or tables
. Select Join
Tables from the suggested command completions.
Left table
— Name of table or timetableSpecify the name from a list of all the nonempty tables and timetables that are in the workspace.
Right table
— Name of table or timetableSpecify the name from a list of all the nonempty tables and timetables that are in the workspace.
Merging variable
— Name of table variable with key valuesSpecify the name of a variable from a list of variables in the left or right table.
The drop-down list for the left table contains a full list of its variables.
The drop-down list for the right table contains a subset of variables. The list of merging variables from the right table is constrained by your choice of merging variables from the left table.
When you specify a merging, or key, variable, its values determine which rows are merged from the left and right tables. To specify multiple sets of merging variables, use the + button.
Combine merging variable
— Check box for combining left and right merging variablesoff
(default) | on
Combine corresponding merging variables when performing outer joins. By default, outer joins copy key variables from the left and right tables to their own variables in the output table. To combine corresponding key variables in the left and right tables into one variable in the output, select this check box.