Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

Tutorial on Fuzzy Logic using

MATLAB
Adel Abdennour,
Electrical Engineering Department,
King Saud University

Outline
Fuzzy Logic Toolbox
FIS Editor
Tipping Problem: Fuzzy Approach

Defining Inputs & Outputs


Defining MFs
Defining Fuzzy Rules

MATLAB: Fuzzy Logic Toolbox

MATLAB: Fuzzy Logic Toolbox

FIS Editor

Tipping Problem
Given a number between 0 and 10 that represents the quality

of service at a restaurant (where 10 is excellent), and another


number between 0 and 10 that represents the quality of the
food at that restaurant (again, 10 is excellent), what should
the tip be?
Assume that an average tip is 15%, a generous tip is 25%, and a

cheap tip is 5%.

Tipping Problem: Fuzzy Approach


Antecedent
Service
Food
Consequent
Tip
Membership Function
Service : poor , good, excellent
Food : rancid, delicious
Tip : cheap, average, generous

FIS Editor: Adding Input / Output

Tipping Problem: Defining Input & outputs

Tipping Problem: Membership Function


Membership Function: Service
Let,
Poor
: 0-5
Good
: 2.5 7.5
Excellent : 5- 10

Tipping Problem: Membership Function

Tipping Problem: Membership Function


Membership

Function:

Tip
Let,
Cheap

: 0 - 15
Average
: 7.5 22.5
Generous : 15 - 30

13

Tipping Problem: Fuzzy Rules


What we want to express is:
Rancid

Delicious

Poor

Cheap

Average

Good

Cheap

Average

Excellent

Generous

Generous

or
1.
2.
3.
4.
5.

If service is poor and the food is rancid then tip is cheap


If service is good and the food is rancid then tip is cheap
If service is poor and the food is delicious then tip is Average
If service is good and the food is delicious then tip is Average
If service is excellent then tip is generous

We have just defined the rules for a fuzzy logic system.

Tipping Problem: Fuzzy Rules

Tipping Problem: Fuzzy Rules

Saving FIS

Rule Viewer

Surface Viewer

You might also like