On Tue, Jun 26, 2012 at 3:53 PM, Robert T. Short
<address@hidden> wrote:
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.
More fun than what I was doing...
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.
I noticed your shift-and-or of z is really sort of a convolution. How about:
x = conv(a, [1 1 1])
y = conv(x, [1 1 1])
z = y >= 6
z = z(3:end-2)