www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/InnerJoinOperationofTableswithOneVariableinCommonExample.m

    %% Inner-Join Operation of Tables with One Variable in Common  

%% 
% Create a table, |A|. 
A = table([5;12;23;2;6],...
    {'cereal';'pizza';'salmon';'cookies';'pizza'},...
    'VariableNames',{'Age','FavoriteFood'})  

%% 
% Create a table, |B|, with one variable in common with |A|. 
B = table({'cereal';'cookies';'pizza';'salmon';'cake'},...
    [110;160;140;367;243],...
    {'A-';'D';'B';'B';'C-'},...
    'VariableNames',{'FavoriteFood','Calories','NutritionGrade'})  

%% 
% Use the |innerjoin| function to create a new table, |C|, with data from
% tables |A| and |B|. 
C = innerjoin(A,B) 

%%
% Table |C| is sorted by the key variable, |FavoriteFood|.