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

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

%% 
% Find the unique elements of |A| with the current behavior. 
A = [9 2 9 5];
[C1, ia1, ic1] = unique(A)  

%% 
% Find the unique elements of |A|, and preserve the legacy behavior. 
[C2, ia2, ic2] = unique(A, 'legacy')