www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/OuterJoinOperationofTableswithOneVariableinCommonExample.m
%% Outer-Join Operation of Tables with One Variable in Common %% % Create a table, |A|. A = table([5;12;23;2;15;6],... {'cheerios';'pizza';'salmon';'oreos';'lobster';'pizza'},... 'VariableNames',{'Age','FavoriteFood'},... 'RowNames',{'Amy','Bobby','Holly','Harry','Marty','Sally'}) %% % Create a table, |B|, with one variable in common with |A|, called |FavoriteFood|. B = table({'cheerios';'oreos';'pizza';'salmon';'cake'},... [110;160;140;367;243],... {'A-';'D';'B';'B';'C-'},... 'VariableNames',{'FavoriteFood','Calories','NutritionGrade'}) %% % Use the |outerjoin| function to create a new table, |C|, with data from % tables |A| and |B|. C = outerjoin(A,B) %% % Table |C| contains a separate variable for the key variable from |A|, % called |FavoriteFood_A|, and the key variable from |B|, called |FavoriteFood_B|.