%% Merge Tables Using Left and Right Keys
% 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 Var1 from table Tleft, but in a different order.

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

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

[T,iright] = join(Tleft,Tright,'LeftKeys',1,'RightKeys',2)

% T is the horizontal concatenation of Tleft and Tright(iright,1).
% Copyright 2012 The MathWorks, Inc.