Fuzzy Logic Experiments
Fuzzy Logic Experiments
Ex. No: 1
Date:
Aim :
To write a Program in MATLAB to perform union, intersection and complement
operations of fuzzy set.
Algorithm:
1. Read the membership values of two fuzzy sets.
2. Perform union operation by using max( ) function.
3. Perform intersection operation by using min( ) function.
4. Perform complement operation by subtracting membership value from 1
5. Display the result.
Program:
Result:
Thus, the MATLAB program to perform Union, Intersection and Complement operations
of two Fuzzy sets has been executed successfully and the output is verified.
Plotting Various Membership Functions
Ex. No: 3
Date:
Aim:
To write a program in MATLAB to plot triangular, trapezoidal and bell shaped
membership functions.
Algorithm:
Program:
x=(0.0:1.0:10.0)’;
subplot(311 )
plot(x,[y1]);
x=(0.0:1.0:10.0)’;
subplot(312)
plot(x, [y1] );
x=(0.0:0.2:10.0);
y1=gbellmf (x,[3 5 7]);
subplot(313)
plot(x, [y1]);
Result:
Thus, the MATLAB program for plotting membership functions has been executed
successfully and the output is verified.
Implementation of Fuzzy Inference System
Ex. No: 5
Date:
Aim :
To implement a Fuzzy Inference System (FIS) for which the inputs, output and rules are
given as below.
INPUTS: Temperature and Cloud Cover
Temperature: {Freeze, Cool, Warm and Hot}
Cloud Cover: {Sunny, Partly Cloud and Overcast}
OUTPUT: Speed
Speed : {Fast and Slow}
RULES:
1. If cloud cover is Sunny and temperature is warm, then drive Fast
Sunny (Cover) and Warm (Temp) -> Fast (Speed)
2. If cloud cover is cloudy and temperature is cool, then drive Slow
Cloudy (Cover) and Cool (Temp) -> Slow (Speed)
Procedure
1. Go to command window in Matlab and type fuzzy.
2. Now, new Fuzzy Logic Designer window will be opened.
3. Input / Output Variable
a. Go to Edit Window and click Add variable.
b. As per our requirements create two input variables, Temperature and Cloud
Cover.
c. Create one output variable, Speed.
4. Temperature:
a. Double click the Temperature input variable in Fuzzy Logic Designer window.
b. New window will be opened and remove all the Membership Functions.
c. Now, Go to Edit and Click Add MFs and select the 4 Parameters for Temperature
Class.
d. Change the following fields as mentioned data in the given below table.
Inputs : Temperature Freezing, Cool, Warm and Hot
MF1: MF2: MF3: MF4:
Range : [0 110] Range : [0 110] Range : [0 110] Range : [0 110]
Name : Freezing Name : Cool Name : Warm Name : Hot
Type : trapmf Type : trimf Type : trimf Type : trapmf
Parameter [0 0 30 50] Parameter [30 50 70] Parameter [50 70 90] Parameter [70 90 110 110]
5. Similarly, add the data’s to the Cloud Cover variables and Speed variables.
6. Cloud Cover:
7. Speed:
Created rules
Output
Result:
Thus a Fuzzy Inference System is implemented for temperature, cloud cover and speed
using the given rules.
Simple Fuzzy Set Operations
Ex. No: 6
Date:
Aim:
To write a MATLAB program to find algebraic sum, algebraic subtraction, algebraic
product, bounded sum, bounded subtraction and bounded product of two fuzzy sets.
Algorithm:
1. Read the values of the two fuzzy sets.
2. Perform the algebraic sum operation by,
A + B = (a + b) – (a * b)
Program:
a= input(‘Enter the fuzzy set a’ )
c= a + b
d= a * b
as= c – d
e= 1 – b
ad= a + e
f= a – b
g= c – 1
disp(as)
disp(ad)
disp(d)
disp(bs)
disp (bd)
disp(bp)
Output:
[1.0000 0.6000 ]
[1 0.9000]
[0.4000 0.1000]
[1.0000 0.7000]
[0.6000 0.3000]
[0.4000 0]
Result:
Thus, a program to perform simple fuzzy set operations has been executed and successfully
verified.