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

    %% Difference of Two Vectors with Specified Output Order  
% Use the |setOrder| argument to specify the ordering of the values in |C|.   

%% 
% Specify |'stable'| or |'sorted'| when the order of the values in |C| are
% important. 
A = [3 6 2 1 5 1 1]; 
B = [2 4 6];
[C,ia] = setdiff(A,B,'stable')  

%% 
% Alternatively, you can specify |'sorted'| order. 
 [C,ia] = setdiff(A,B,'sorted')