MATLAB: Removing repeated values from an array

array manipulation

Suppose I have an array [1.2 8 89 1.2 4 8 32 1.2]. Is there any MATLAB function that gives me the array without repeated values: [1.2 8 89 4 32]?!

Best Answer

Y=[1.2 8 89 1.2 4 8 32 1.2]
unique(Y) % The result is sorted
%or
unique(Y,'stable') % the result is not sorted