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

    %% Intersection of Two Vectors and Their Indices  

%% 
% Create two vectors with values in common. 
A = [7 1 7 7 4]; 
B = [7 0 4 4 0];  

%% 
% Find the values common to both |A| and |B|, as well as the index vectors
% |ia| and |ib|, such that |C = A(ia)| and |C = B(ib)|. 
[C,ia,ib] = intersect(A,B)