help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: uniq like function?


From: Olaf Till
Subject: Re: uniq like function?
Date: Fri, 16 Apr 2010 09:33:28 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

On Fri, Apr 16, 2010 at 02:55:07PM +0800, Evan wrote:
> I know there is a function of "unique" which returns unique elements.
> I occasionally need a function like the "uniq" command under bash
> which only omit adjacent repeated elements. For example, uniq ([1, 2,
> 2, 3, 2, 2]) returns [1, 2, 3, 2]. Is there already such a function in
> octave? Thanks in advance.

What about (v is your vector):

v = [v(v(1:end-1) != v(2:end)), v(end)]

Olaf


reply via email to

[Prev in Thread] Current Thread [Next in Thread]