2、
else if((bc)
return 0;
}
/****************三角形反模糊化处理**********************/
float cuf(float x,float a,float b,float c)
{
float y,z;
z=(b-a)*x+a;
y=c-(c-b)*x;
return (y+z)/2;
}
/*****************梯形(左)求隶属度 模糊化*******************/
float ufl(floa
3、t x,float a,float b)
{
if(x<=a)
return 1;
else if((ab)
return 0;
}
/*******************梯形反模糊化***********************/
float cufl(float x,float a,float b)
{
return b-(b-a)*x;
}
/*****************梯形(右)求隶属度 模糊化*******************/
float uf
4、r(float x,float a,float b)
{
if(x<=a)
return 0;
if((a=b)
return 1;
}
/*******************梯形反模糊化***********************/
float cufr(float x,float a,float b)
{
return (b-a)*x +a;
}
/*******************求交集***********************/
float fand(float a,fl
5、oat b)
{
return (a
6、PS,PS,ZO,ZO},
{PM,PM,PM,PS,ZO,NS,NS},
{PM,PM,PS,ZO,NS,NM,NM},
{PS,PS,ZO,NS,NS,NM,NM},
{PS,ZO,NS,NM,NM,NM,NB},
{ZO,ZO,NM,NM,NM,NB,NB}};
es[NB]=ufl(e,-3,-1);
es[NM]=uf(e,-3,-2,0);
es[NS]=uf(e,-3,-1,1);
es[ZO]=uf(e,-2,0,2);
es[PS]=uf(e,-1,1,3);
es[PM]=uf(e,0,2,3);
es[PB]=ufr(e,1,3);
ec
7、s[NB]=ufl(ec,-0.3,-0.1);//ec
ecs[NM]=uf(ec,-0.3,-0.2,0);
ecs[NS]=uf(ec,-0.3,-0.1,0.1);
ecs[ZO]=uf(ec,-0.2,0,0.2);
ecs[PS]=uf(ec,-0.1,0.1,0.3);
ecs[PM]=uf(ec,0,0.2,0.3);
ecs[PB]=ufr(ec,0.1,0.3);
/******模糊推理 规则的可信度通过取小点运算得到*****/
float form[7][7];
int i,j;
for(i=0;i<7;i++)
{
float w,h,r;
8、 for(j=0;j<7;j++)
{
h=es[i];
r=ecs[j];
w=fand(h,r);
form[i][j]=w;
}
}
/*************求得的最大值赋给form[a][b]*********/
int a=0,b=0;
for(i=0;i<7;i++)
{
for(j=0;j<7;j++)
{
if(form[a][b]