From: Adam Hart on
x(find(diff([x;eps])))

I think this fixes the problem. (unless the last value of x is eps)

x(find([diff(x);1]))

That should also do the trick. No matter the scenario, you always want to grab the last value.



Alistair W Smith <aws33(a)student.canterbury.ac.nz> wrote in message <3BE86E6C.E9769800(a)student.canterbury.ac.nz>...
> Ralph-Uwe Boerner wrote:
> >
> > A non-sorting version would be
> >
> > >> x(find(diff(x)))
>
> Be careful with this. diff(x) is one shorter than x, and so you'll miss
> the last value.
>
> Al.
From: Matt Fig on
There is no need to use find.

x = round(rand(1,15)*5)
y = sort(x);
y = y([true diff(y)~=0])