MATLAB: How to find unique elements in a vector without using unique or find

arrayunique

I have A=randi(100,1,100); How can I find unique values in array and show them without using unique() and find() .

Best Answer

Use an histogram based approach (works only for positive integers)
%get M random numbers from 1 to N
M=10; N=25;
A=randi(N,1,M)
%find unique values
x=1:N;
unique_vals = x(logical(accumarray(A',1,[N,1])))
Related Question