help-octave
[Top][All Lists]
Advanced

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

Re: filtering logical array


From: Robert T. Short
Subject: Re: filtering logical array
Date: Tue, 26 Jun 2012 12:53:14 -0700
User-agent: Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120614 Thunderbird/13.0.1

On 06/26/2012 11:48 AM, Jordi Gutiérrez Hermoso wrote:
a=[0 0 1 1 1 1 1 0 1 0 1 0 0 1 0 0 1 1 0 0 0 0 0 1 1 1 0]
Kind of a fun problem.  Here is another solution.


a = [0 0 1 1 1 1 1 0 1 0 1 0 0 1 0 0 1 1 0 0 0 0 0 1 1 1 0]
x = conv(a,[1 1 1])
z = x>2
z = z | shift(z,-1) | shift(z,-2)
z = z(1:length(a))

There is probably a much more elegant way to do the last two lines but it isn't coming to me.

Bob





reply via email to

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