%% Keep One Copy of Nonkey Variables
% Create a new table with data from tables Tleft and Tright. If any nonkey variables have the same name in both tables, keep only the copy from table Tleft.
% Create a table, Tleft.

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

%
% 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],[10;3;8;8;4])

%
% Create a new table, T, with data from tables Tleft and Tright. Use Var2 as a key variable to the join function and keep only the copy of Var1 from table Tleft. The output table T does not contain the Var1 data from table Tright.

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

% Copyright 2012 The MathWorks, Inc.