logo for matrixlab-examples.com
[?] Subscribe To This Site

XML RSS
Add to Google
Add to My Yahoo!
Add to My MSN
Subscribe with Bloglines


Home
Matrixmania Blog
Contact
-> Sitemap <-
Matlab Books
Quick Matlab Guide
Matlab Tutorials
Matlab Examples
Matlab Flow Control
Boolean Algebra
Linear Algebra
Matlab 2D Plots
Matlab 3D Plots
Matlab GUI
Matlab Cookbook I
Matlab Cookbook II
Probability and Stats
Forums and Help
Relevant Links
Fun!
Your own Website?
Terms/Policies
leftimage for matrixlab-examples.com

De Morgan Laws

In Boolean Algebra, there are some very important laws which are called the De Morgan's laws (the spelling can change from author to author).

These laws teach us how to interchange NOT with AND or OR logical operators.

Using gates (commonly used in Digital Electronics), they can be expressed in two forms:

the OR form:
De Morgan's laws

the AND form:
DeMorgan's law


In Matlab, these laws can be demonstrated very easily.
Let's create a script file like this:



% Let x and y be column vectors
x = [0 0 1 1]'
y = [0 1 0 1]'

% We can demonstrate the OR form of the law
% with these two lines
x_or_y = x|y
DeMorg1 = not(not(x)& not(y))

% We can demonstrate the AND form of the law
% with these two lines
x_and_y = x&y
DeMorg2 = not(not(x) | not(y))



When we run it, we get this output:

x =

     0
     0
     1
     1
y =

     0
     1
     0
     1

x_or_y =

     0
     1
     1
     1
DeMorg1 =

     0
     1
     1
     1
x_and_y =

     0
     0
     0
     1

DeMorg2 =

     0
     0
     0
     1

Which demonstrates the De Morgan's laws.


From 'De Morgan laws' to home
From 'De Morgan laws' to 'Boolean Algebra'

footer for de morgans laws page