模糊PID的C语言程序文.pdfVIP

  • 14
  • 0
  • 约3.19千字
  • 约 4页
  • 2021-11-15 发布于福建
  • 举报
论域 e:[-3,3] ec:[-0.3,0.3] kp:[-0.3,0.3] #define NB 0 #define NM 1 #define NS 2 #define ZO 3 #define PS 4 #define PM 5 #define PB 6 /************** 求隶属度(三角形)模糊化处理 ***************/ float uf(float x,float a,float b,float c) { if(x=a) return 0; else if((ax)(x=b)) return (x-a)/(b-a); else if((bx)(x=c)) return (c-x)/(c-b); else if(xc) 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(float x,float a,float b) { if(x=a) return 1; else if((ax)(x=b)) return (b-x)/(b-a); else if(xb) return 0; } /******************* 梯形反模糊化 ***********************/ float cufl(float x,float a,float b) { return b-(b-a)*x; } /***************** 梯形 (右 ) 求隶属度 模糊化 *******************/ float ufr(float x,float a,float b) { if(x=a) return 0; if((ax)(xb)) return (x-a)/(b-a); if(x=b) return 1; } /******************* 梯形反模糊化 ***********************/ float cufr(float x,float a,float b) { return (b-a)*x +a; } /******************* 求交集 ***********************/ float fand(float a,float b) { return (ab)?a:b; } /******************* 求并集 ***********************/ float forr(float a,float b) { return (ab)?b:a; } /******************* 主函数 ***********************/ void main() { /******************* 模糊规则表 ***********************/ int kp[7][7]={{PB,PB,PM,PM,PS,ZO,ZO}, {PB,PB,PM,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,

文档评论(0)

1亿VIP精品文档

相关文档