Neuro Fuzzy System
Neuro Fuzzy System
Neuro Fuzzy System
PRACTICAL FILE
SUBMITTED BY -
Himanshu Bansal
41413204917
8th Sem EEE
SUBMITTED TO –
Mrs. Deepali Sharma
Himanshu Bansal
41413204917
Experiment - 1
AIM : Consider any two fuzzy sets A and B and find A ∪ B, A ꓵ B, A’ and B’ by using a
MATLAB program.
Mathematical Concept
A fuzzy set A˜ in the universe of information U can be defined as a set of ordered pairs and it
can be represented mathematically as −
A˜ = {(y,μA˜(y))|y∈U}
μA˜∩B˜(y)=μA˜∧μB˜ ∀y∈U
μA˜=1−μA˜(y) y∈U
Himanshu Bansal
41413204917
MATLAB Code
Output:
Conclusion
Himanshu Bansal
41413204917
The results of operations on fuzzy sets i.e, union, intersection and complements are obtained.
Himanshu Bansal
41413204917
Experiment - 2
Mathematical Concept
A fuzzy set A˜ in the universe of information U can be defined as a set of ordered pairs and it
can be represented mathematically as −
A˜ = {(y,μA˜(y))|y∈U}
1. Difference
MATLAB Code
Himanshu Bansal
41413204917
% Experiment 2 - Calculate A ∩ B'(difference),B ∩ A' by using a MATLAB prog
% Himanshu Bansal/ 41413204917
clc
clear
A = input('Enter the first Fuzzy Set : ')
B = input('Enter the second Fuzzy Set : ')
option = input('Enter the option : ');
% Option 1 - A - B
% Option 2 - B - A
if (option == 1)
[m, n] = size(B);
Bcomp = ones(m) - B
diff1 = min(A, Bcomp)
end
if (option == 2)
Output:
Conclusion
The results of operations on fuzzy sets i.e, differences are obtained.
Himanshu Bansal
41413204917
Experiment - 3
Mathematical Concept
A fuzzy set A˜ in the universe of information U can be defined as a set of ordered pairs and it
can be represented mathematically as −
A˜ = {(y,μA˜(y))|y∈U}
DEMORGAN’S LAW
Demorgan's Law states that the complement of the union of two sets is the intersection of
their complements and the complement of the intersection of two sets is the union of their
complements. These are mentioned after the great mathematician De Morgan. This law can
be expressed as
Himanshu Bansal
41413204917
MATLAB Code
clc
clear
A = input('Enter fuzzy set matrix A - ');
B = input('Enter fuzzy set matrix B - ');
option = input('Enter the option - ');
%Option 1 = (A U B)' = A' intersection B'
%Option 2 = (A intersection B)' = A' U B'
[m, n] = size(A);
Acomp = ones(m) - A
[j, k] = size(B);
Bcomp = ones(j) - B
if(option == 1)
RHS = min(Acomp, Bcomp)
AUB = max(A, B);
[c, d] = size(AUB);
LHS = ones(c) - AUB
if(LHS == RHS)
disp("Demorgan's law is verified")
end
elseif (option == 2)
RHS = max(Acomp, Bcomp)
k = min(A, B);
[c, d] = size(k);
LHS = ones(c) - k
Output:
Himanshu Bansal
41413204917
Conclusion
Himanshu Bansal
41413204917
Experiment - 4
AIM : Find fuzzy relation using max-min method for any given two vectors R and S.
Mathematical Concept
A fuzzy set A˜ in the universe of information U can be defined as a set of ordered pairs and it
can be represented mathematically as −
A˜ = {(y,μA˜(y))|y∈U}
Fuzzy relation in different product space can be combined with each other by the operation
called “Composition”. There are many composition methods in use , e.g. max-product
method, max-average method and max-min method. But max-min composition method is
best known in fuzzy logic applications.
Let R (x, y), (x, y ∈A × B) and S (y, z) ,(y, z) ∈B× C) be the two relations. The max- min
composition is then the fuzzy set
R○S= {[(x,y), maxy{min { μR(x,y), μS(y.z)}}] x∈ A,y ∈B,c∈ C}
Himanshu Bansal
41413204917
MATLAB Code
% Experiment 4 - Find fuzzy relation using max-min method for any given two
vectors R and S
% Himanshu Bansal - 41413204917
clc
clear
R = input('Enter the first Matrix : ');
S = input('Enter the second Matrix : ');
[m, n] = size(R);
[a, b] = size(S);
if(n == a)
for i = 1:m
for j = 1:b
c = R(i, :);
d = S(:, j);
f = d';
e = min(c, f);
h(i, j) = max(e)
end
end
Output:
Conclusion
Himanshu Bansal
41413204917
Experiment - 5
AIM : Using MATLAB program to draw triangular and Gaussian Membership function,
given x = 0 t 10 with increment of 0.1.
Theory :
f(x;a,b,c)=max(min(x-a/b-a , c-x/c-b),0)
The parameters a and c locate the “feet” of the triangle and the parameter b locates the peak.
f(x;σ,c)=e-(x-c) 2/2 σ 2
The parameters for gaussian mf represent the parameters σ and c listed in order in the vector
[sig c].
MATLAB Code :
Himanshu Bansal
41413204917
Output :
Himanshu Bansal
41413204917
Experiment - 6
AIM : Consider any fuzzy matrix R and find the crisp lambda cut set relation for lambda 0.6.
Theory :
In this method a fuzzy set A is transformed into a crisp set Aλ for a given value of λ (0
≤ λ ≤ 1).
In other-words, Aλ = {x|µA(x) ≥ λ}.
That is, the value of Lambda-cut set Aλ is x, when the membership value
corresponding to x is greater than or equal to the specifified λ.
This Lambda-cut set Aλ is also called alpha-cut set.
If R and S are two fuzzy relations, defifined with the same fuzzy sets over the same
universe of discourses, then
5
(R ∪ S)λ = Rλ ∪ Sλ
6
(R ∩ S)λ = Rλ ∩ Sλ
MATLAB Code :
% Experiment 6 - Consider any fuzzy matrix Rand find the crisp lambda cut s
relation for lambda 0.6.
% Himanshu Bansal - 41413204917
clc
R = input('Enter the matrix value : ');
lambda = input('Enter the lambda value : ');
[m, n] = size(R);
for i = 1 : m
for j = 1 : n
if(R(i, j) < lambda)
b(i, j) = 0;
else
Output :
Himanshu Bansal
41413204917
Conclusion : The crisp lambda cut set relation for lambda 0.6 is obtained.
Himanshu Bansal
41413204917
Experiment - 7
AIM : Write a program to implement AND function using perceptron networks with bipolar
inputs and outputs.
Theory :
A perceptron is an algorithm for supervised learning of binary classifiers. This enables you to
distinguishes between the two linearly separable classes +1 and -1.A single-layer perceptron is
the basic unit of a neural network. Perceptrons can be viewed as building blocks in a single
layer in a neural network, made up of four different parts:
3. Net sum
4. Activation function
A neural network, which is made up of perceptrons, can be perceived as a complex logical
statement (neural network) made up of very simple logical statements (perceptrons); of
“AND” and “OR” statements.
Himanshu Bansal
41413204917
MATLAB Code :
clc
x = [1 1 -1 -1; 1 -1 1 -1];
t = [1 -1 -1 -1];
w = [0 0];
b = 0;
alpha = input('Enter Learning rate = ');
theta = input('Enter threshold value = ');
con = 0;
epoch = 0;
while con == 0
for i = 1 : 4
yin = b + x(1, i)*w(1)+x(2, i)*w(2);
if yin > theta
y = 1;
end
if yin<= theta && yin >= -theta
y = 0;
end
if yin < -theta
y = -1;
end
if (y - t(i))
con = 1;
for j = 1 : 2
w(j) = w(j) + alpha * t(i) * x(j, i);
end
b = b + alpha*t(i);
end
end
epoch = epoch + 1;
Output :
Himanshu Bansal
41413204917
Conclusion : Implemented AND function using perceptron networks with bipolar inputs and
outputs.
Himanshu Bansal
41413204917
Experiment - 8
AIM : Write a program to implement OR function using ADALINE with bipolar inputs and
outputs.
Theory :
Adaline which stands for Adaptive Linear Neuron, is a network having a single linear unit. It
was developed by Widrow and Hoff in 1960. Some important points about Adaline are as
follows −
A two-input Adaline.
Himanshu Bansal
41413204917
MATLAB Code :
clc
disp('Adaline network for OR function bipolar inputs and outputs');
x1 = [1 1 -1 -1];
x2 = [1 -1 1 -1];
x3 = [1 1 1 1];
t = [1 1 1 -1];
w1 = 0.1;
w2 = 0.1;
b = 0.1;
alpha = 0.1;
e = 2;
delw1 = 0;
delw2 = 0;
delb = 0;
epoch = 0;
while(e > 1.018)
epoch = epoch + 1;
e = 0;
for i = 1 : 4
nety(i) = w1 * x1(i) + w2 * x2(i) + b;
nt = [nety(i), t(i)];
delw1 = alpha * (t(i) - nety(i)) * x1(i);
delw2 = alpha * (t(i) - nety(i)) * x2(i);
delb = alpha * (t(i) - nety(i)) * x3(i);
wc = [delw1 delw2 delb]
w1 = w1 + delw1;
w2 = w2 + delw2;
b = b + delb;
w = [w1 w2 b]
x = [x1(i) x2(i) x3(i)];
pnt = [x nt wc w];
Himanshu Bansal
41413204917
Output :
Himanshu Bansal
41413204917