www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/UnionofTwoVectorsandTheirIndicesExample.m
%% Union of Two Vectors and Their Indices %% % Define two vectors with a value in common. A = [5 7 1]; B = [3 1 1]; %% % Find the union of vectors |A| and |B|, as well as the index vectors, |ia| % and |ib|. [C,ia,ib] = union(A,B) %% % The values in |C| are the combined values of |A(ia)| and |B(ib)|.