π \pi π型隶属度函数
隶属度函数的形状和符号
π
\pi
π相似,使用fuzzy logical toolbox
函数实现
% 建立pi型隶属度函数
x=0:0.1:10;
y=pimf(x, [1, 4, 5, 10]); % 参数表示图像绘制
plot(x, y);
xlabel('input values');
ylabel('output values');
grid on;
Gaussian型隶属度函数
%% gaussian型隶属度函数
x=0:0.1:10;
y=gaussmf(x, [2, 5]); % if-then形式表示对象控制,5表示中心点,2表示图形宽度
plot(x, y);
xlabel('input values');
ylabel('output values');
grid on;
钟型隶属度函数
%% 钟型隶属度函数
x=0:0.1:10;
y=gbellmf(x, [2, 4, 6]);
plot(x, y);
xlabel('input values');
ylabel('output values');
grid on;
S型隶属度函数
%% S型隶属度函数
x=0:0.1:10;
y=smf(x, [1 8]);
plot(x, y);
xlabel('input values');
ylabel('output values');
grid on;
梯形隶属度函数
%% 梯形隶属度函数
x=0:0.1:10;
y=trapmf(x, [1 5 7 8]);
plot(x, y);
xlabel('input values');
ylabel('output values');
grid on;
三角型隶属度函数
%% 三角型隶属度函数
x=0:0.1:10;
y=trimf(x, [2 6 7]);
plot(x, y);
xlabel('input values');
ylabel('output values');
grid on;
Z型隶属度
%% Z型隶属度函数
x=0:0.1:10;
y=zmf(x, [2 6]);
plot(x, y);
xlabel('input values');
ylabel('output values');
grid on;
应用:模糊控制系统
建立一个分数-奖励的模糊推理系统
%% 模糊推理系统
fisMat=newfis('ss');
fisMat=addvar(fisMat,'input','scores',[0 10]);
fisMat=addvar(fisMat,'output','gains',[0 100]);
fisMat=addmf(fisMat,'input',1,'BAD','gaussmf',[1.2 0]);
fisMat=addmf(fisMat,'input',1,'MED','gaussmf',[1.2 5]);
fisMat=addmf(fisMat,'input',1,'GOOD','gaussmf',[1.2 10]);
fisMat=addmf(fisMat,'output',1,'Low','trapmf',[0 0 10 50]);
fisMat=addmf(fisMat,'output',1,'Mid','trimf',[10 30 80]);
fisMat=addmf(fisMat,'output',1,'High','trapmf',[50 80 100 100]);
rulelist=[1 1 1 1;2 2 1 1; 3 3 1 1];
fisMat=addrule(fisMat,rulelist);
subplot(3,1,1);plotmf(fisMat,'input',1);xlabel('scores');ylabel('input membership');
subplot(3,1,2);plotmf(fisMat,'output',1);xlabel('gains');ylabel('out membership')
subplot(3,1,3);gensurf(fisMat);