Professional Documents
Culture Documents
Index: S.No Title Remarks
Index: S.No Title Remarks
INDEX
Objective:
Implementation of fuzzy sets on classical set using MATLAB
Software Required:
Windows OS, MATLAB, MS-word
CODE:
N = 501; legend('A','B','A+B')
minX = -20; subplot(2,1,2)
maxX = 20; plot(x,A,'--',x,B,':',x,Csub,'c')
x = linspace(minX,maxX,N); title('Fuzzy Subtraction, A-B')
A=trapmf(x,[-10-213]); legend('A','B','A-B')
B = gaussmf(x,[2 5]); figure
Csum = fuzarith(x,A,B,'sum'); subplot(2,1,1)
Csub = fuzarith(x,A,B,'sub'); plot(x,A,'--',x,B,':',x,Cprod,'c')
Cprod = fuzarith(x,A,B,'prod'); title('Fuzzy Multiplication, A*B')
Cdiv = fuzarith(x,A,B,'div'); legend('A','B','A*B')
figure subplot(2,1,2)
subplot(2,1,1) plot(x,A,'--',x,B,':',x,Cdiv,'c')
plot(x,A,'--',x,B,':',x,Csum,'c') title('Fuzzy Division, A/B')
title('Fuzzy Addition, A+B') legend('A','B','A/B')
OUTPUT:
Experiment- 2
Objective
Writea program in MATLAB to perform Union,IntersectionandComplement
operations.
Software Required:
Windows OS, MATLAB, MS-word
CODE:
%Enter Data
u=input('Enter First Matrix');
v=input('Enter Second Matrix');
%To Perform Operations
w=max(u,v);
p=min(u,v);
q1=1-u;
q2=1-v;
%Display Output
display('Union Of Two Matrices');
display(w);
display('Intersection Of Two Matrices');
display(p);
display('Complement Of First Matrix');
display(q1);
display('Complement Of Second Matrix');
display(q2);
Output:-
UnionOfTwoMatrices
w =0.3000 0.7000
Program No. 5
i) Input
iii) Output
The Water Level is considered as the Input variable and Valve status is taken as Output Variable.
The Input-Output Variable’s Membership functions should be plotted along with their ranges:-
The following screen appearance is obtained by clicking on the FIS Rule system indicator:-
Rules are added by selecting variable’s values and clicking on add rule menu each time a new
rule is added.
Water Level(ok,low,high)
The output in accordance with the input and rules provided by user is shown as(view-rule
viewer):-
Output
Experiment- 4
Objective:
Write Implementing
aIm
MpATlemLeAB tatip
nsimplerogr
on of fa
umzzyfose
perceptron r tP
s eon
model rctocleshow
patssireffects
on
can eof
l set tfuinput,
osir nan AN ATD
gweights
M LA fBunction
and bias onwith bipolarboundary
decision
iputs
n
Software Required:
Windows OS, MATLAB, MS-word
CODE:
% Perceptron for AND Function
clear;
clc;
t=[1 -1 -1 -1];
w=[0 0];
b=0;
con=1;
epoch=0;
while con
con=0;
for i=1:4
yin=b+x(1,i)*w(1)+x(2,i)*w(2);
if yin>theta
y=1;
end
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;
end
disp(w);
disp('Final Bias');
disp(b);
Output :-
1 1
Final Bias
-1
Experiment 5
Objective:
Design, implement and train a feed forward ANN for pattern recognition problems.
Software Required:
Windows OS, MATLAB, MS-word
Code:
[X,T] = bodyfat_dataset;
net = fitnet(15);
view(net)
[net,tr] = train(net,X,T);
Nntraintool
nntraintool('close') plotperform(tr)
graph testX = X(:,tr.testInd);
testT = T(:,tr.testInd);
testY = net(testX);
perf = mse(net,testT,testY)
perf = 33.2344
Y = net(X);
plotregression(T,Y)
e = T - Y;
ploterrhist(e)
Outputs and graphs
View of network
Training of network
Best Validatio n Performance is 34.4082 at ep.Fch 3
Errors
Objective:
Implementation of fuzzy based controller on washing machine.
Software Required:
ans = 12.6650
>>a=readfis('washtime');
evalfis([0.635 .245 .5 .5 20 ], a)
ans = 22.0962
plotfis(a),
Using following commands we obtain the MFs for different LIs and LOs
plotmf(a,'input',2)
plotmf(a,'input',3)
plotmf(a,'output',1)
>>gensurf(a)
>>ruleview(a)
>>surfview(a)
>>plotfis(a)
>>surfview(a)
By the use of fuzzy logic control we have been able to obtain a wash time, rinse period and spin period for
different type of dirt and different degree of dirt and different type of cloths. The conventional method required the
human interruption to decide upon what should be the wash time for different cloths. In other words this situation
analysis ability has been incorporated in the machine which makes the machine much more automatic and represents
the decision taking power of the new arrangement.
Here the sensors sense the input values and using the above Model the inputs are fuzzyfied and then by using
simple if-else rules and other simple fuzzy set operations the output fuzzy function is obtained and using the criteria
the output value for wash time, rinse period and spin period is obtained.
The results (the above plot) shows the way the machine will response in different conditions. This is quite
convincing and appropriate.
V. CONCLUSION
By the use of proposed fuzzy logic Controller, we have been able to obtain different Wash Time, Rinse Period,
Spin Period (output Variable) for different Type of Dirt, Dirtiness of Clothes, Types of Clothes, Mass of Clothes and
Temperature (Input Variable). This analysis also leads to saving in electrical energy and time for washing the
clothes by using proposed Washing Machine. This proposed advance and automatic sensor system based Washing
Machine depicts the advantage of Fuzzy Logic Controller in the conventional Washing Machine.
REFERENCES
[1] L.A. Zadeh, Fuzzy Sets, Information and Control, 338–353, (1965)
[2] Han H., Chun-Yi and Yury. S, Adaptive Control of a Class of Non-linear Systems with Non-Linearly Parameterized Fuzzy Approximation.
IEEE Transactions on Fuzzy Systems, V0l.9, No.2, 315-323, (2001)
[3] Workman, M. Hardware requirement for Fuzzy Logic Control Systems. Lubbock, TX: Texas Tech University, (1996)
[4] George J. Kilr and Bo Yuan, Fuzzy Sets and Fuzzy Logic (India: PHI, 1995)
[5] Sonia Chhabra , VHDL Implementation of Fuzzy Control System, (2006)
[6] Dharamniwas, Aziz Ahmad, Varun Redhu and Umesh Gupta, Liquid Level Control by Using Fuzzy Logic Controller, International Journal
of Advances in Engineering & Technology, (July 2012). ISSN: 2231-1963.
[7] Ge Zhe-Xue, Sun Zhi-Qiang. Neural N/w Theory and the realization MATLAB (Beijing: Electronics industry publishing, 2007)
th
[8] Lohani P., and Hasan,S.R..Design of an Improved Controller Microchip For Washing Machine, 16 Annual Electronics New Zealand
Conference (pp. 20-26).Dunedin : Otago University (2009)
[9] Manish Aggarwal, Fuzzy Logic Controller for Washing Machine, IIT Kharagpur (2011).
Objective:
Implementation of perceptron learning algorithm in MATLAB
Software Required:
Windows OS, MATLAB, MS-word
CODE:
input = [0 0; 0 1; 1 0; 1 1];
numIn = 4;
desired_out = [0;1;1;1];
bias = -1;
coeff = 0.7;
rand('state',sum(100*clock));
weights = -1*2.*rand(3,1);
iterations = 10;
out = zeros(4,1);
for j = 1:
numIn y = bias*weights(1,1)+…
input(j,1)*weights(2,1)+input(j,2)*weights(3,1);
out(j) = 1/(1+exp(-y));
delta = desired_out(j)-out(j);
weights(1,1) = weights(1,1)+coeff*bias*delta;
weights(2,1) = weights(2,1)+coeff*input(j,1)*delta;
weights(3,1) = weights(3,1)+coeff*input(j,2)*delta;
end
end
OUTPUT:
When running the perceptron over 10 iterations, the outputs begin to converge, but are
still not precisely as expected:
out =
0.3756
0.8596
0.9244
0.9952
weights =
0.6166
3.2359
2.7409
0.0043
0.9984
0.9987
1.0000
weights =
5.4423
12.1084
11.8823