-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMembershipFunctions_3.m
122 lines (112 loc) · 2.44 KB
/
MembershipFunctions_3.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
x = [0:1:20];
y = x;
% triangle MF
ua1 = trimf(x,[5 10 15]);
ub1 = trimf(y,[5 10 15]);
% trapezoid MF
ua2 = trapmf(x,[3 8 12 17]);
ub2 = trapmf(y,[3 8 12 17]);
% min (mamdani)
mamdani1 = zeros(length(x),length(y));
for i=1:length(x),
for j=1:length(y),
mamdani1(i,j) = min([ua1(i),ub1(j)]);
end
end
subplot(2,4,1);
mesh(x,y,mamdani1);
xlabel('A');
ylabel('B');
title('triangle min');
mamdani2 = zeros(length(x),length(y));
for i=1:length(x),
for j=1:length(y),
mamdani2(i,j) = min([ua2(i),ub2(j)]);
end
end
subplot(2,4,5);
mesh(x,y,mamdani2);
xlabel('A');
ylabel('B');
title('trapezoid min');
% algebraic product
algebraic1 = zeros(length(x),length(y));
for i=1:length(x),
for j=1:length(y),
algebraic1(i,j) = ua1(i)*ub1(j);
end
end
subplot(2,4,2);
mesh(x,y,algebraic1);
xlabel('A');
ylabel('B');
title('triangle algebraic product');
algebraic2 = zeros(length(x),length(y));
for i=1:length(x),
for j=1:length(y),
algebraic2(i,j) = ua2(i)*ub2(j);
end
end
subplot(2,4,6);
mesh(x,y,algebraic2);
xlabel('A');
ylabel('B');
title('trapezoid algebraic product');
% bounded product
bounded1 = zeros(length(x),length(y));
for i=1:length(x),
for j=1:length(y),
bounded1(i,j) = max(0,(ua1(i)+ub1(j)-1));
end
end
subplot(2,4,3);
mesh(x,y,bounded1);
xlabel('A');
ylabel('B');
title('triangle bounded product');
bounded2 = zeros(length(x),length(y));
for i=1:length(x),
for j=1:length(y),
bounded2(i,j) = max(0,(ua2(i)+ub2(j)-1));
end
end
subplot(2,4,7);
mesh(x,y,bounded2);
xlabel('A');
ylabel('B');
title('trapezoid bounded product');
% drastic product
drastic1 = zeros(length(x),length(y));
for i=1:length(x),
for j=1:length(y),
if(ub1(j)==1)
drastic1(i,j) = ua1(i);
elseif(ua1(i)==1)
drastic1(i,j) = ub1(j);
else
drastic1(i,j) = 0;
end
end
end
subplot(2,4,4);
mesh(x,y,drastic1);
xlabel('A');
ylabel('B');
title('triangle drastic product');
drastic2 = zeros(length(x),length(y));
for i=1:length(x),
for j=1:length(y),
if(ub2(j)==1)
drastic2(i,j) = ua2(i);
elseif(ua2(i)==1)
drastic2(i,j) = ub2(j);
else
drastic2(i,j) = 0;
end
end
end
subplot(2,4,8);
mesh(x,y,drastic2);
xlabel('A');
ylabel('B');
title('trapezoid drastic product');