Professional Documents
Culture Documents
Use MATLAB
OUTLINE
OUTLINE
XXX.fis
SystemInputOutputRule
(trimf)
(trapmf)(gbellmf)(gaussmf)
2(gauss2mf)sigmfdsigmfpsigmf
pimfsmfzmf
(Rule) ifthen
Trimf
Trapmf
Gbellmf
Sigmf
Dsigmf
Psigmf
Pimf
Smf
Zmf
Gaussmf
Gauss2mf
(RULE)
1.
2.
1.
2.
1.
2.
1 2, 1(1):1
1 3, 2(1):2
ABC
OUTLINE
EXAMPLE:TIPPER
MATLABM-file
SYSTEM
[System]
%[]System,Inputs,OutputsRules
Name='tipper1';
%tipper1.fis
Type='mamdani';
NumInputs=2;
NumOutputs=1;
NumRules=3;
AndMethod='min';
%Mamdani style
%
%
%
%
OrMethod='max';
ImpMethod='min';
AggMethod='max';
DefuzzMethod='centroid';
INPUT1
[Input1]
Name='service';
Range=[0 10];
NumMFs=3;
MF1='poor':'gaussmf',[1.5 0];
MF2='good':'gaussmf',[1.5 5];
MF3='excellent':'gaussmf',[1.5 10];
%
%
%
%
%
%
%
INPUT1
INPUT2
[Input2]
Name='food';
Range=[0 10];
NumMFs=2;
MF1='rancid':'trapmf',[0 0 1 3];
MF2='delicious':'trapmf',[7 9 10 10];
INPUT2
OUTPUT1
[Output1];
Name='tip';
Range=[0 30];
NumMFs=3;
MF1='cheap':'trimf',[0 5 10];
MF2='average':'trimf',[10 15 20];
MF3='generous':'trimf',[20 25 30];
OUTPUT1
RULES
RULES
[Rules]
1 1, 1 (1) : 2;
2 0, 2 (1) : 2;
3 2, 3 (1) : 2;
tipper1.fis
tipper1.fisMATLAB
tipper=readfis('tipper1');
tipper
evalfis([5 5],tipper)
ans=
15.0000
plotmf(tipper,'input',1)
showrule(tipper)
showrule(tipper,[1 3],'symbolic')
surfview(tipper)
%
%
OUTLINE
INPUT/OUTPUT
SERVICE
FOOD
TIP
TIPPER
TIPPER
OUTLINE
DEMO
load mgdata.dat
time = mgdata(:, 1);
x = mgdata(:, 2);
for t=118:1117,
Data(t-117,:)=[x(t-18) x(t-12) x(t-6) x(t) x(t+6)];
end
trnData=Data(1:500, :);
chkData=Data(501:end, :);
MGDATA
FIS
fismat = genfis1(trnData);
%fismat=genfis1(inputData,2,'gauss2mf','constant');
ANFIS
[fismat1,error1,ss,fismat2,error2] = anfis(trnData,fismat,[],[],chkData);
ANFIS
anfis_output = evalfis([trnData(:,1:4); chkData(:,1:4)],fismat2);
index = 125:1124;
subplot(211), plot(time(index), [x(index) anfis_output]);
xlabel('Time (sec)');
title('MG Time Series and ANFIS Prediction');
subplot(212), plot(time(index), x(index) - anfis_output);
xlabel('Time (sec)');
title('Prediction Errors');
OUTLINE
DEMO
MATLAB command window
load fuzex1trnData.dat
load fuzex2trnData.dat
load fuzex1chkData.dat
load fuzex2chkData.dat
WORKSPACE
FIS
FIS
ANFIS
ANFIS
Thanks!!