Personally, I haven't used Octave in a number of years.
Hence: this page is outdated!
Boolean Algebra
In Boolean algebra you represent the logical values true and false by the numbers 1 and 0 respectively.
>>> true ans = 1 >>> false ans = 0
and, or, not
The basic operators in logic are and, or and not, these are written using the symbols ∧, ∨ and ¬ respectively. If p and q are statements that are either true or false, then you get the truth table
 p
 true
 true
 false
 false
 q
 true
 false
 true
 false
 p ∧ q
 true
 false
 false
 false
 p ∨ q
 true
 true
 true
 false
 ¬p
 false
 false
 true
 true
The operators ∧ and ∨ are binary operators, they are applied to two operands. The operator ¬ is an unary operator, it applies to one operand.
In Octave (and most other programming languages) the operators ∧, ∨
and ¬ are written using the symbols &&
, 
and !
; giving the truth
table
 p
 1
 1
 0
 0
 q
 1
 0
 1
 0

p
&&
q  1
 0
 0
 0

p

q  1
 1
 1
 0
 !p
 0
 0
 1
 1
In Octave (and most other programming languages) all numbers that are not 0 are thought of as being true.
>>> a=4.5; >>> b=0; >>> (a && b)  !b ans = 1
Note that you can perform logical operations by using arithmetics.
p &&
q = pq
p 
q = p+qpq
!p = 1p
further info:
Fuzzy Logics: This article was published in Scientific American 1993, A Partly True Story, by Ian Stewart
That is true → ← That is false
by Malin Christersson under a Creative Commons AttributionNoncommercialShare Alike 2.5 Sweden License