📄 defuzzdm.html
字号:
<html xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--This HTML is auto-generated from an M-file.To make changes, update the M-file and republish this document. --> <title>Defuzzification Methods</title> <meta name="generator" content="MATLAB 7.1"> <meta name="date" content="2005-07-28"> <meta name="m-file" content="defuzzdm"> <link rel="stylesheet" type="text/css" href="../../../matlab/demos/private/style.css"> </head> <body> <div class="header"> <div class="left"><a href="matlab:edit defuzzdm">Open defuzzdm.m in the Editor</a></div> <div class="right"><a href="matlab:echodemo defuzzdm">Run in the Command Window</a></div> </div> <div class="content"> <h1>Defuzzification Methods</h1> <introduction> <p>Display five defuzzification methods supported in the Fuzzy Logic Toolbox.</p> </introduction> <h2>Contents</h2> <div> <ul> <li><a href="#1">Five Methods</a></li> <li><a href="#2">Centroid</a></li> <li><a href="#3">Bisector</a></li> <li><a href="#4">Middle, Smallest, and Largest of Maximum</a></li> <li><a href="#5">Picking a method</a></li> </ul> </div> <h2>Five Methods<a name="1"></a></h2> <p>Suppose you have the following region to be defuzzified. What are some of the methods you might choose?</p><pre class="codeinput">x = -10:0.1:10;mf1 = trapmf(x,[-10 -8 -2 2]);mf2 = trapmf(x,[-5 -3 2 4]);mf3 = trapmf(x,[2 3 8 9]);mf1 = max(0.5*mf2,max(0.9*mf1,0.1*mf3));plot(x,mf1,<span class="string">'LineWidth'</span>,3);set(gca,<span class="string">'YLim'</span>,[-1 1],<span class="string">'YTick'</span>,[0 .5 1])</pre><img vspace="5" hspace="5" src="defuzzdm_01.png"> <h2>Centroid<a name="2"></a></h2> <p>Centroid defuzzification returns the center of area under the curve. If you think of the area as a plate of equal density, the centroid is the point along the x axis about which this shape would balance. </p><pre class="codeinput">x1 = defuzz(x,mf1,<span class="string">'centroid'</span>)h1 = line([x1 x1],[-0.2 1.2],<span class="string">'Color'</span>,<span class="string">'k'</span>);t1 = text(x1,-0.2,<span class="string">' centroid'</span>,<span class="string">'FontWeight'</span>,<span class="string">'bold'</span>);</pre><pre class="codeoutput">x1 = -3.2281</pre><img vspace="5" hspace="5" src="defuzzdm_02.png"> <h2>Bisector<a name="3"></a></h2> <p>The bisector is the vertical line that will divide the region into two sub-regions of equal area. It is sometimes, but not always coincident with the centroid line. </p><pre class="codeinput">x2 = defuzz(x,mf1,<span class="string">'bisector'</span>)gray = 0.7*[1 1 1];set([h1 t1],<span class="string">'Color'</span>,gray)h2 = line([x2 x2],[-0.4 1.2],<span class="string">'Color'</span>,<span class="string">'k'</span>);t2 = text(x2,-0.4,<span class="string">' bisector'</span>,<span class="string">'FontWeight'</span>,<span class="string">'bold'</span>);</pre><pre class="codeoutput">x2 = -3.7000</pre><img vspace="5" hspace="5" src="defuzzdm_03.png"> <h2>Middle, Smallest, and Largest of Maximum<a name="4"></a></h2> <p>MOM, SOM, and LOM stand for Middle, Smallest, and Largest of Maximum, respectively. These three methods key off the maximum value assumed by the aggregate membership function. In this example, because there is a plateau at the maximum value, they are distinct. If the aggregate membership function has a unique maximum, then MOM, SOM, and LOM all take on the same value. </p><pre class="codeinput">x3 = defuzz(x,mf1,<span class="string">'mom'</span>)x4 = defuzz(x,mf1,<span class="string">'som'</span>)x5 = defuzz(x,mf1,<span class="string">'lom'</span>)set([h2 t2],<span class="string">'Color'</span>,gray)h3 = line([x3 x3],[-0.7 1.2],<span class="string">'Color'</span>,<span class="string">'k'</span>);t3 = text(x3,-0.7,<span class="string">' MOM'</span>,<span class="string">'FontWeight'</span>,<span class="string">'bold'</span>);h4 = line([x4 x4],[-0.8 1.2],<span class="string">'Color'</span>,<span class="string">'k'</span>);t4 = text(x4,-0.8,<span class="string">' SOM'</span>,<span class="string">'FontWeight'</span>,<span class="string">'bold'</span>);h5 = line([x5 x5],[-0.6 1.2],<span class="string">'Color'</span>,<span class="string">'k'</span>);t5 = text(x5,-0.6,<span class="string">' LOM'</span>,<span class="string">'FontWeight'</span>,<span class="string">'bold'</span>);</pre><pre class="codeoutput">x3 = -5x4 = -2x5 = -8</pre><img vspace="5" hspace="5" src="defuzzdm_04.png"> <h2>Picking a method<a name="5"></a></h2> <p>Which of these methods is the right one? There's no simple answer. But if you want to get started quickly, generally the centroid method is good enough. Later you can always change your defuzzification method to see if another method works better. </p><pre class="codeinput">set([h3 t3 h4 t4 h5 t5],<span class="string">'Color'</span>,gray)set([h1 t1],<span class="string">'Color'</span>,<span class="string">'red'</span>)</pre><img vspace="5" hspace="5" src="defuzzdm_05.png"> <p class="footer">Copyright 1994-2004 The MathWorks, Inc.<br> Published with MATLAB® 7.1<br></p> </div> <!--##### SOURCE BEGIN #####%% Defuzzification Methods% Display five defuzzification methods supported in the Fuzzy Logic Toolbox.% Copyright 1994-2004 The MathWorks, Inc. % $Revision: 1.9.2.2 $ $Date: 2004/04/04 03:24:11 $%% Five Methods% Suppose you have the following region to be defuzzified. What are some of the% methods you might choose?x = -10:0.1:10;mf1 = trapmf(x,[-10 -8 -2 2]);mf2 = trapmf(x,[-5 -3 2 4]);mf3 = trapmf(x,[2 3 8 9]);mf1 = max(0.5*mf2,max(0.9*mf1,0.1*mf3));plot(x,mf1,'LineWidth',3);set(gca,'YLim',[-1 1],'YTick',[0 .5 1])%% Centroid% Centroid defuzzification returns the center of area under the curve. If you% think of the area as a plate of equal density, the centroid is the point along% the x axis about which this shape would balance.x1 = defuzz(x,mf1,'centroid')h1 = line([x1 x1],[-0.2 1.2],'Color','k'); t1 = text(x1,-0.2,' centroid','FontWeight','bold');%% Bisector% The bisector is the vertical line that will divide the region into two% sub-regions of equal area. It is sometimes, but not always coincident with the% centroid line.x2 = defuzz(x,mf1,'bisector')gray = 0.7*[1 1 1];set([h1 t1],'Color',gray)h2 = line([x2 x2],[-0.4 1.2],'Color','k'); t2 = text(x2,-0.4,' bisector','FontWeight','bold');%% Middle, Smallest, and Largest of Maximum% MOM, SOM, and LOM stand for Middle, Smallest, and Largest of Maximum,% respectively. These three methods key off the maximum value assumed by the% aggregate membership function. In this example, because there is a plateau at% the maximum value, they are distinct. If the aggregate membership function has% a unique maximum, then MOM, SOM, and LOM all take on the same value.x3 = defuzz(x,mf1,'mom')x4 = defuzz(x,mf1,'som')x5 = defuzz(x,mf1,'lom')set([h2 t2],'Color',gray)h3 = line([x3 x3],[-0.7 1.2],'Color','k'); t3 = text(x3,-0.7,' MOM','FontWeight','bold');h4 = line([x4 x4],[-0.8 1.2],'Color','k'); t4 = text(x4,-0.8,' SOM','FontWeight','bold');h5 = line([x5 x5],[-0.6 1.2],'Color','k'); t5 = text(x5,-0.6,' LOM','FontWeight','bold');%% Picking a method% Which of these methods is the right one? There's no simple answer. But if you% want to get started quickly, generally the centroid method is good enough.% Later you can always change your defuzzification method to see if another% method works better.set([h3 t3 h4 t4 h5 t5],'Color',gray)set([h1 t1],'Color','red')##### SOURCE END #####--> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -