%% Inner-Join Operation of 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, with common values in the second variable as the first variable of table Tleft.

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

%
% Use the innerjoin function to create a new table, T, with data from tables Tleft and Tright. Use the first variable of Tleft and the second variable of Tright as key variables.

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

% Table T retains only the rows that match between Tleft and Tright with respect to the key variables.
% Table T contains the horizontal concatenation of Tleft(ileft,:) and Tright(iright,'Var1').
% Copyright 2012 The MathWorks, Inc.