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

    %% Preserve Legacy Behavior of union  
% Use the |'legacy'| flag to preserve the behavior of |union| from R2012b
% and prior releases in your code.   

%% 
% Find the union of |A| and |B| with the current behavior. 
A = [5 7 1]; 
B = [3 1 1];
[C1,ia1,ib1] = union(A,B)  

%% 
% Find the union of |A| and |B|, and preserve the legacy behavior. 
A = [5 7 1]; 
B = [3 1 1];
[C2,ia2,ib2] = union(A,B,'legacy')