Professional Documents
Culture Documents
Use MATLAB
OUTLINE
Fuzzy logic toolbox Fuzzy: use command line Fuzzy: use GUI ANFIS: use command line ANFIS: use GUI
OUTLINE
Fuzzy logic toolbox Fuzzy: use command line Fuzzy: use GUI ANFIS: use command line ANFIS: use GUI
(trimf) (trapmf) (gbellmf) (gaussmf) 2(gauss2mf) sigmf dsigmf psigmf pimf smf zmf (Rule) ifthen
(RULE)
1. 2.
1. 2.
1. 2.
1 2, 1(1):1 1 3, 2(1):2
ABC
OUTLINE
Fuzzy logic toolbox Fuzzy: use command line Fuzzy: use GUI ANFIS: use command line ANFIS: use GUI
EXAMPLE:TIPPER
MATLAB
M-file
SYSTEM
[System] % [] Name='tipper1'; Type='mamdani'; NumInputs=2; NumOutputs=1; NumRules=3; AndMethod='min'; OrMethod='max'; ImpMethod='min'; System,Inputs,Outputs Rules % tipper1.fis %Mamdani style % % % %
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'; %
INPUT2
OUTPUT1
[Output1]; Name='tip'; %
OUTPUT1
RULES
If (service is poor) or (food is rancid) then (tip is cheap) (1) If (service is good) then (tip is average) (1) If (service is excellent) or (food is delicious) then (tip is generous) (1)
RULES
[Rules] 1 1, 1 (1) : 2; 2 0, 2 (1) : 2; 3 2, 3 (1) : 2; %
tipper1.fis
plotmf(tipper,'input',1)
% %
surfview(tipper)
OUTLINE
Fuzzy logic toolbox Fuzzy: use command line Fuzzy: use GUI ANFIS: use command line ANFIS: use GUI
fuzzy
INPUT/OUTPUT
SERVICE
FOOD
TIP
TIPPER
TIPPER
OUTLINE
Fuzzy logic toolbox Fuzzy: use command line Fuzzy: use GUI ANFIS: use command line ANFIS: use GUI
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
Fuzzy logic toolbox Fuzzy: use command line Fuzzy: use GUI ANFIS: use command line ANFIS: use GUI
anfisedit
DEMO
MATLAB command window load fuzex1trnData.dat load fuzex2trnData.dat load fuzex1chkData.dat load fuzex2chkData.dat
WORKSPACE
FIS
FIS
ANFIS
ANFIS
Thanks!!