%% Preserve Legacy Behavior of intersect
% Use the 'legacy' flag to preserve the behavior of intersect from R2012b and prior releases in your code.
% Find the intersection of A and B with the current behavior.

A = [7 1 7 7 4]; 
B = [7 0 4 4 0];
[C1,ia1,ib1] = intersect(A,B)

%
% Find the unique elements of A and preserve the legacy behavior.

[C2,ia2,ib2] = intersect(A,B,'legacy')

% Copyright 2012 The MathWorks, Inc.