x = some_vector_values;
[Y,I]=sort(x); %sort in order, get indices
dy=gradient(Y); %get difference vector same size as input vector
ind=find(dy~=0);%ignore places that are equal to the value of interest
for m = 1 : length(ind)
do_such_and_such to Y(ind(m));
end