% ---- 2009-5-17 ---- % ----------------------------- x=14;
% define input type in fuzzy zone y0 = gaussmf(x, [1 0]); y1 = gaussmf(x, [1 3]); y2 = gaussmf(x, [1 6]); y3 = gaussmf(x, [1 9]); y4 = gaussmf(x, [1 12]); y5= gaussmf(x, [1 15]); y6= gaussmf(x, [1 18]); a=[y0 y1 y2 y3 y4 y5 y6]; b=max(a);
% caculate input in fuzzy zone,get input_type and input_authorityvalue if x<=18 & x>=0 if b==a(1) type='NB'; authorityvalue=y0; elseif b==a(2) type='NM'; authorityvalue=y1; elseif b==a(3) type='NS'; authorityvalue=y2; elseif b==a(4) type='ZE'; authorityvalue=y3; elseif b==a(5) type='PS'; authorityvalue=y4;
13 / 27
elseif b==a(6) type='PM'; authorityvalue=y5; else b==a(7) type='PB'; authorityvalue=y6; end else if x>18 type='PB'; authorityvalue=1; elseif x<0 type='NB'; authorityvalue=1; end end type authorityvalue % caculate output by if type=='NB'
out=authorityvalue*15;
% if input is NB, then output is PB; elseif type=='NM' out=authorityvalue*10;
% if input is NM, then output is PM; elseif type=='NS' out=authorityvalue*5;
% if input is NS, then output is PS; elseif type=='ZE' out=authorityvalue*0.001;
14 / 27
% if input is ZE, then output is ZE; elseif type=='PS' out=-authorityvalue*5;
% if input is PS, then output is NS; elseif type=='PM' out=-authorityvalue*10;
% if input is PM, then output is NM; else type=='PB'
out=-authorityvalue*15;
% if input is PB, then output is NB; end out ×÷Òµ£º
1.Éè¼ÆÒ»¸öÄ£ºý¿ØÖÆÆ÷£¬Âú×ãÈçÏÂÌõ¼þ£º
ÊäÈ룺-100-100·¶Î§ÄÚ·ÖΪÆß¸öÂÛÓò£¬NB NM NS ZE PS PM PB£»Á¥Êô¶Èº¯ÊýÂú×ã¸ß˹·Ö²¼£»
Êä³ö£º0µ½100·¶Î§ÄÚ·ÖΪÆß¸öÂÛÓò£¬NB NM NS ZE PS PM PB£¬Á¥Êô¶Èº¯ÊýΪ³£Êý1¡£
Ä£ºýÍÆÀí¹ý³Ì£¬output=ÊäÈëÁ¥Êô¶Èº¯ÊýÖµ*Êä³öÂÛÓòµÄÖÐÐÄÖµ¡£ ¿ØÖƹæÔò£º
% % if input is NB, then output is PB; % % if input is NM, then output is PM; % % if input is NS, then output is PS; % % if input is ZE, then output is ZE; % % if input is PS, then output is NS; % % if input is PM, then output is NM; % % if input is PB, then output is NB;
15 / 27
³ÌÐòΪ£º
x1 = (-100:0.1:100)'; y0 = gaussmf(x1, [10 -100]); y1 = gaussmf(x1, [10 -66]); y2 = gaussmf(x1, [10 -33]); y3 = gaussmf(x1, [10 0]); y4 = gaussmf(x1, [10 33]); y5 = gaussmf(x1, [10 66]); y6 = gaussmf(x1, [10 100]); plot(x1,[y0 y1 y2 y3 y4 y5 y6]);
2.³ÌÐòΪ£º x=14;
% define input type in fuzzy zone y0 = gaussmf(x, [10 -100]); y1 = gaussmf(x, [10 -66]); y2 = gaussmf(x, [10 -33]);
16 / 27
Ïà¹ØÍÆ¼ö£º