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

% Copyright 2012 The MathWorks, Inc.