www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/InnerJoinOperationofTablesUsingLeftandRightKeysExample.m
%% Inner-Join Operation of Tables Using Left and Right Keys %% % Create a table, |A|. A = table([10;4;2;3;7],[5;4;9;6;1],[10;3;8;8;4]) %% % Create a table, |B|, with common values in the second variable as the % first variable of table |A|. B = table([6;1;1;6;8],[2;3;4;5;6]) %% % Use the |innerjoin| function to create a new table, |C|, with data from % tables |A| and |B|. Use the first variable of |A| and the second variable % of |B| as key variables. [C,ia,ib] = innerjoin(A,B,'LeftKeys',1,'RightKeys',2) %% % Table |C| retains only the rows that match between |A| and |B| with respect % to the key variables. %% % Table |C| contains the horizontal concatenation of |A(ia,:)| and |B(ib,'Var1')|.