3. Relations and Logical Operations

In this section you should think of 1 as "true" and 0 as "false". The notations &, |, ~ stand for "and", "or" and "not", respectively. The notation == is a check for equality. Try these

a=[1, 0, 1, 0]
b=[1, 1, 0, 0]
a==b
a<=b
~a
a&b
a&~a
a|b
a|~a

The function any is used to determine whether there is a nonzero entry in a vector. The function all determines if all the entries are zero. Try

a
any(a)
all(a)
c=zeros(1,4)
d=ones(1,4)
any(c)
all(d)
e=[a', b', c', d']
any(e)
all(e)
any(all(e))


Next Section: 4. Colon Notation


Created by F.G. Garvan (fgarvan@ufl.edu) on Tue, Sep 30, 97
Last update made Thu Oct 2 11:22:14 EDT 1997.
Back to Table of Contents
EMAIL: fgarvan@ufl.edu fgarvan@ufl.edu