The following code removes duplicate values
numarr = [1 2 2 3 3 3 4 4 4 4];
%// Filter doubled values
[n_, bin] = histc(numarr, unique(numarr));
multiple_ = find(n_ > 1);
mult_indices_ = ismember(bin, multiple_);
numarr(mult_indices_) = [];
%// output
numarr = 1
How to adapt it, that the first occurence of any duplicate remains?
i.e. that the output will be
numarr =
1 2 3 4
uniquefunction.