Presentation is loading. Please wait.

Presentation is loading. Please wait.

Boolean Algebra Lecture 7: Supporting Material Dr Kathryn Merrick Tuesday 24 th March, 2009.

Similar presentations


Presentation on theme: "Boolean Algebra Lecture 7: Supporting Material Dr Kathryn Merrick Tuesday 24 th March, 2009."— Presentation transcript:

1 Boolean Algebra Lecture 7: Supporting Material Dr Kathryn Merrick Tuesday 24 th March, 2009

2

3 Overview Revision of numerical types and operators Introduction to the Boolean type and operators Boolean logic

4 Revision: Numerical Types integer floating point number Examples: >> num_motors = 2; >> speed = 5.6; …

5 Revision: Numerical Operators +addition – subtraction /division *multiplication ^power =assignment Examples: >> result = 2 + 3; >> num_legs = 4; >> my_var = 4^2; …

6 Another Puzzle… You have a goat a wolf and a cabbage with you and you need to cross a river in a small boat to get back home. If left alone together, the goat will eat the cabbage and the wolf will eat the goat. With room for only two in the boat, how do you get to the other side of the river? How do we express things like ‘the goat will eat the cabbage’ in a programming language?

7 Demo 1: Boolean Types in MATLAB

8 The Boolean Type Can have two values: true false In MATLAB these are equivalent to 1 and 0 respectively Can be combined using logical operators &, | and ~ Behaviour of logical operators can be represented in truth tables

9 Demo 2: Boolean Operators in MATLAB

10 Summary: Boolean Operators &logical AND |logical OR ~logical NOT <less than <=less than or equal to >greater than >=greater than or equal to ==equal to ~=not equal to

11 Summary After today’s lecture you should be able to: Identify numerical operators Identify Boolean operators Use Boolean logic to create and evaluate Boolean expressions


Download ppt "Boolean Algebra Lecture 7: Supporting Material Dr Kathryn Merrick Tuesday 24 th March, 2009."

Similar presentations


Ads by Google