www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/UnionofRowsinTwoMatricesExample.m
%% Union of Rows in Two Matrices %% % Define two matrices with a row in common. A = [2 2 2; 0 0 1]; B = [1 2 3; 2 2 2; 2 2 2]; %% % Find the combined rows of |A| and |B|, with no repetition, as well as % the index vectors |ia| and |ib|. [C,ia,ib] = union(A,B,'rows') %% % The rows of |C| are the combined rows of |A(ia,:)| and |B(ib,:)|.