how to connect Fuzzy inference system with ANFIS

1 visualización (últimos 30 días)
ciptya almira
ciptya almira el 18 de Jul. de 2017
helloo i need your help for my case i have to build fuzzy inference system at the command line like this
[System]
Name='myfile'
Type='sugeno'
Version=2.0
NumInputs=2
NumOutputs=1
NumRules=4
AndMethod='min'
OrMethod='max'
ImpMethod='prod'
AggMethod='max'
DefuzzMethod='centroid'
[Input1]
Name='x1'
Range=[3 9]
NumMFs=2
MF1='rendah':'gbellmf',[1.2 2.5 3]
MF2='tinggi':'gbellmf',[1.2 2.5 9]
[Input2]
Name='x2'
Range=[1000 3000]
NumMFs=2
MF1='apresiasi':'gbellmf',[400 2.5 1000]
MF2='depresiasi':'gbellmf',[400 2.5 3000]
[Output1]
Name='output'
Range=[1000 3000]
NumMFs=4
MF1='line1':'linear',[0 0 0]
MF2='line2':'linear',[0 0 0]
MF3='line3':'linear',[0 0 0]
MF4='line4':'linear',[0 0 0]
[Rules]
1 0, 1 (1) : 1
2 0, 2 (1) : 1
1 1, 3 (1) : 1
2 2, 4 (1) : 1
and i want to connect them with my anfis code like this
function [c,a,R,y,yr,coef,Et] = anhfis(A,yTarget,klas, lr, mc, maxEpoch, Eps);
[a,c,U,obj_fcn] = findDevMean(A, klas)
E = 1;
epoh = 0;
[n,m] = size(A);
y = yTarget
while (epoh < maxEpoch & E>Eps),
epoh = epoh+1;
Mu = zeros(n,klas,m)
E=0;
%lapisan 1,2,3
coef = [];
for i=1 : n,
for k=1 : klas,
w1(k) = 1;
for j = 1 : m,
mf (k,j) = 1/(1+((A(i,j)-c(k,j))/a(k,j))^2);
We1(i,k,j) = w1(k)*mf(k,j);
Mu(i,k,j) = mf(k,j)
end;
if m>1,
We2(i,k) = We1(i,k,1)*We1(i,k,2);
else
We2 = We1;
end;
end;
for k=1 : klas,
We3(i,k) = We2(i,k)/sum(We2(i,:));
end;
cc=[];
for k=1 : klas,
cc = [cc We3(i,k)*A(i,:) We3(i,k)];
end;
coef = [coef; cc];
end;
%lapisan 45
youtput =[]
for i=1:n,
for k=1:klas,
for j=1:m,
We4(i,k) = ((We3(i,k)*A(i,j))*coef(i,k+0)) + coef(i,k+1)
end;
end;
for j=1:m,
youtput(i,j) = sum(We4(i,:))/A(i,j)
end;
end;
X = coef
R = rekursif_LSE(X,y)
yr = X*R
nn1 = fix(length(R)/klas)
for i =1:n,
for k=1:klas,
yt(i,k) = X(i,(k-1)*nn1+1:k*nn1)*R((k-1)*nn1+1:k*nn1)
end;
end;
%propagasierror
for i=1:n,
E5 = -2*(y(i)-yr(i))
for k=1:klas,
E4(i,k) = E5
end;
for k=1:klas,
E3(i,k) = yt(i,k)*E4(i,k)
end;
for k=1:klas,
tt=0;
for t=1:klas,
for j=1:m,
if t~=k,
tt = tt+We1(i,t,j)
end;
end;
end;
if m>2
E2(i,k)= tt/(sum(We1(i,:,1))^2)*E3(i,k)
else
E2(i,k)= tt/(sum(We1(i,:,k))^2)*E3(i,k)
end;
for t=1:klas,
if t~=k,
if m>2
E2(i,k) = E2(i,k)-(tt/(sum(We1(i,:,1))^2))*E3(i,t)
else
E2(i,k) = E2(i,k)-(tt/(sum(We1(i,:,k))^2))*E3(i,t)
end;
end;
end;
end;
for j=1:m,
for k=1:klas,
tt =1
if m>1,
for t=1:m,
if t~=j,
tt = tt*Mu(i,k,t)
end;
end;
else
tt = tt*Mu(i,k,t)
end;
E1(j,k) = tt*E2(i,k)
end;
end;
%perubahan bobot a dan c(da & dc)
for j=1:m,
for k=1:klas,
L = A(i,j)-c(j,k)
H = (1+(L/a(j,k))^2)^2
da(j,k) = 2*(L^2)/((a(j,k)^3)*H)*E1(j,k)*lr*A(i,j)
dc(j,k) = 2*L/((a(j,k)^2)*H)*E1(j,k)*lr*A(i,j)
if epoh>1,
da(j,k) = mc*dalama(j,k)+(1-mc)*da(j,k)
end;
if epoh>1,
dc(j,k) = mc*dclama(j,k)+(1-mc)*dc(j,k)
end;
a(j,k) = a(j,k)+ da(j,k)
c(j,k) = c(j,k) + dc(j,k)
dclama(j,k) = dc(j,k)
dalama(j,k) = da(j,k)
end;
end;
%hitung sse
E = E + (y(i)-yr(i))^2
chkRMSE = norm(yr(i)-y(i))/sqrt(length(yr(i)));
%mean(E) % Mean Squared Error
%RMSE = sqrt(mean(E)); % Root Mean Squared Error
end;
Et(epoh) = E
rmse(epoh) = chkRMSE
plot(1:epoh,Et);
title(['Epoh ->' int2str(epoh)]);
handles = guidata( findobj(0, 'tag', 'sse'));
Sse = num2str(Et(epoh));
set(handles.sse,'string',Sse);
handles = guidata( findobj(0, 'tag', 'rmse'));
RMSE = num2str(rmse(epoh))
set(handles.rmse,'string',RMSE);
grid
pause(0.001);
end;
hasil = [y yr y-yr]
setappdata(0,'gethasil',hasil)
myicon = imread('checklist.png');
h=msgbox('proses pembelajaran selesai','alhamdulillah','custom',myicon);
but i don't know how to connect them. thank you

Respuestas (0)

Categorías

Más información sobre Fuzzy Logic Toolbox en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by