Page 53 - Algorithm Collections for Digital Signal Processing Applications using MATLAB
P. 53
1. Artificial Intelligence 41
5.5 M-program for the Realization of Fuzzy Logic
System for the Specifications given in Section 5.4
___________________________________________________________
fuzzygv . m
posx=[0 3 5 7 10];
maxx=max(posx);
posx=posx/max(posx);
posy=[0 20 45 65 100];
maxy=max(posy);
posy=posy/max(posy);
posz=[0 35 70 90 100];
maxz=max(posz);
posz=posz/max(posz);
i=posx(1):1/999:posx(2);
j=(posx(2)):(1/999):posx(3);
k=(posx(3)):(1/999):posx(4);
l=(posx(4)):(1/999):posx(5);
xsmall=[1/posx(2)*i (-1/(posx(3)-posx(2))*(j-posx(3))) zeros(1,length([k l]))];
xmedium =[zeros(1,length([i])) (1/(posx(3)-posx(2))*(j-posx(2))) (-1/(posx(4)-
posx(3))*(k-posx(4))) zeros(1,length([l]))];
xlarge=[zeros(1,length([i j])) (1/(posx(4)-posx(3))*(k-posx(3))) (-1/(posx(5)-posx(4))*(l-
posx(5))) ];
figure
plot([i j k l]*maxx,xsmall,':');
hold
plot([i j k l]*maxx,xmedium,'-');
plot([i j k l]*maxx,xlarge,'--');
xlabel('crisp value')
ylabel('fuzzy value')
title('XINPUT')
i=posy(1):1/999:posy(2);
j=(posy(2)):(1/999):posy(3);
k=(posy(3)):(1/999):posy(4);
l=(posy(4)):(1/999):posy(5);
ysmall=[1/posy(2)*i (-1/(posy(3)-posy(2))*(j-posy(3))) zeros(1,length([k l]))];