[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: elementwise boolean operations
From: |
Przemek Klosowski |
Subject: |
Re: elementwise boolean operations |
Date: |
Thu, 20 May 2010 14:07:16 -0400 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100330 Fedora/3.0.4-1.fc12 Lightning/1.0b1 Thunderbird/3.0.4 |
On 05/20/2010 01:49 PM, Judd Storrs wrote:
I think& and | will do what you want. There are functional forms too:
and(), or(), xor(), etc. The functional forms can take multiple
inputs.
Actually, I was just wondering about that. I wanted a truth table of
a complicated logical expression, and I wrote it by a nested for bit=0:1
loop; but there must be a better way. Given that the logical ops take
vector arguments, all I need is a concise way to create a N by 2^N
vector with all bit combinations, i.e.
x=[0 1 0 1; 0 0 1 1]
x =
0 1 0 1
0 0 1 1
xor(x(1,:),x(2,:))
ans =
0 1 1 0
For extra bonus, how do you create those bit strings in Gray encoding
that is useful for Karnaugh maps? i.e.
x=[0 1 1 0];
y=[0 0 1 1];