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

    %% Unique Values in Vector with Specified Order  
% Use the |setOrder| argument to specify the ordering of the values in |C|.   

%% 
% Specify |'stable'| if you want the values in |C| to have the same order
% as in |A|. 
A = [9 2 9 5];
[C, ia, ic] = unique(A,'stable')  

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