[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: filtering logical array
From: |
Mike Miller |
Subject: |
Re: filtering logical array |
Date: |
Tue, 26 Jun 2012 16:51:41 -0400 |
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)
--
mike
- filtering logical array, seektime, 2012/06/26
- Re: filtering logical array, Jordi Gutiérrez Hermoso, 2012/06/26
- Re: filtering logical array, Robert T. Short, 2012/06/26
- Re: filtering logical array,
Mike Miller <=
- Re: filtering logical array, Robert T. Short, 2012/06/26
- Re: filtering logical array, seektime, 2012/06/27
- Re: filtering logical array, Robert T. Short, 2012/06/27
- Re: filtering logical array, Francesco Potortì, 2012/06/27
- Re: filtering logical array, Jordi Gutiérrez Hermoso, 2012/06/29
- Re: filtering logical array, Robert T. Short, 2012/06/29
- Re: filtering logical array, seektime, 2012/06/29
- Re: filtering logical array, Jordi Gutiérrez Hermoso, 2012/06/29
Re: filtering logical array, seektime, 2012/06/26
Re: filtering logical array, zxcasdqwe, 2012/06/30