%% 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')

% Copyright 2012 The MathWorks, Inc.