%% Merge Tables by Specifying One Key Variable
% Create a table, Tleft.

Tleft = table([10;4;2;3;7],[5;4;9;6;1],[10;3;8;8;4])

%
% Create a table, Tright, giving Var2 of table Tright the same contents as Var2 from table Tleft.

Tright = table([6;1;1;6;8],[5;4;9;6;1])

%
% Create a new table, T, containing data from tables Tleft and Tright. Use Var2 in tables Tleft and Tright as the key variable to the join function.

T = join(Tleft,Tright,'Keys','Var2')

% join adds a unique suffix to the nonkey variable, Var1, to distinguish the data from tables Tleft and Tright.
% Copyright 2012 The MathWorks, Inc.