Professional Documents
Culture Documents
Variables de entrada
Variables de salida
C: corto
P: pequeo
N: normal
A: alto
L: largo
Reglas difusas
for h=1:A-1;
y(h)=0;
end
for n=A:B;
y(n)=((x(n)-a)/(b-a));
end
for i=B+1:C;
y(i)=1;
end
for j=C+1:D;
y(j)=((d-x(j))/(d-c));
end
for k=D+1:s;
y(k)=0;
end
DEFUSIFICACION
end
y=(s/t);
n0=7;%enrada leida
k=find(n==n0);%lugar que ocupa e0 en el vector e
subplot(3,1,1),hold on,plot(n0,MN(k),'*',n0,PC(k),'*',n0,NO(k),...
'*',n0,ME(k),'*',n0,AL(k),'*',n0,MA(k),'*',n0,GR(k),'linewidth',5),hold
off
%fusificar e inferencia difusa de mandani
H1=min(MC,MN(k));
H2=min(C,PC(k));
H3=min(P,NO(k));
H4=min(N,ME(k));
H5=min(A,AL(k));
H6=min(L,MA(k));
H7=min(ML,GR(k));
H=max(H1,max(H2,max(H3,max(H4,max(H5,max(H6,H7))))));
subplot(3,1,3),plot(t,H,'linewidth',3)
set(gca,'fontsize',10), legend('t')
axis([5 26 0 1])
%defusificacion
t0=defuzzy(t,H);
hold on,plot(t0*ones(1,3),[0 0.5 1],'r','linewidth',5)
t0
Este cdigo nos obtendr el tiempo para una cantidad de 7 vehculos,
los resultados siguientes:
1
(vehiculos)
MN
0.5 PC
NO
0 ME
0 5 10 15 20 25
AL
cantidad de vehiculos
MA
1 GR
MC
(tiempo)
0.5 C
P
0 N
6 8 10 12 14 16 18 20 22 24 26
A
tiempo en segundos
L
1 ML
t
0.5
0
6 8 10 12 14 16 18 20 22 24 26