Beruflich Dokumente
Kultur Dokumente
1 of 8
jar:file:///C:/Program%20Files/MATLAB/R2011a/help/toolbox/fuzzy/hel...
How to Build Fuzzy Inference Systems Using Custom Functions in the GUI
When you build a fuzzy inference system, as described in Overview of Fuzzy Inference Process, you can replace the
built-in membership functions or inference functions, or both with custom functions. In this section, you learn how to build
a fuzzy inference system using custom functions in the GUI. To learn how to build the system using custom functions at
the command line, see Specifying Custom Membership and Inference Functions in Working from the Command Line .
To build a fuzzy inference system using custom functions in the GUI:
1. Open the FIS Editor by typing fuzzy at the MATLAB prompt.
2. Specify the number of inputs and outputs of the fuzzy system, as described in The FIS Editor.
3. Create custom membership functions, and replace the built-in membership functions with them, as described in
Specifying Custom Membership Functions.
Membership functions define how each point in the input space is mapped to a membership value between 0 and
1.
4. Create rules using the Rule Editor, as described in The Rule Editor.
Rules define the logical relationship between the inputs and the outputs.
5. Create custom inference functions, and replace the built in inference functions with them, as described in
Specifying Custom Inference Functions.
Inference methods include the AND, OR, implication, aggregation and defuzzification methods. This action
generates the output values for the fuzzy system.
The next figure shows the tipping problem example where the built-in Implication and Defuzzification functions
are replaced with a custom implication function, customimp, and custom defuzzification function, customdefuzz,
respectively.
28/7/2558 12:09
2 of 8
jar:file:///C:/Program%20Files/MATLAB/R2011a/help/toolbox/fuzzy/hel...
6. Select View > Surface to view the output of the fuzzy inference system in the Surface Viewer, as described in The
Surface Viewer.
Back to Top
28/7/2558 12:09
3 of 8
jar:file:///C:/Program%20Files/MATLAB/R2011a/help/toolbox/fuzzy/hel...
elseif x(i)<params(6)
y(i)=params(6);
elseif x(i)<params(7)
y(i)=params(7);
elseif x(i)<params(8)
y(i)=params(8);
else
y(i)=0;
end
end
out=.1*y'; % scaling the output to lie between 0 and 1
Note Custom membership functions can include a maximum of 16 parameters for the input argument.
2. Open the FIS Editor by typing fuzzy at the MATLAB prompt, if you have not done so already.
The FIS Editor opens with the default FIS name, Untitled, and contains one input input1, and one output
output1.
3. In the FIS Editor, select Edit > Membership Functions to open the Membership Function Editor.
Three triangular-shaped membership functions for input1 are displayed by default.
4. To replace the default membership function with a custom function in the Membership Function Editor:
a. Select Edit > Remove All MFs to remove the default membership functions for input1.
b. Select Edit > Add Custom MF to open the Custom Membership Function dialog box.
28/7/2558 12:09
4 of 8
jar:file:///C:/Program%20Files/MATLAB/R2011a/help/toolbox/fuzzy/hel...
28/7/2558 12:09
5 of 8
jar:file:///C:/Program%20Files/MATLAB/R2011a/help/toolbox/fuzzy/hel...
This action also adds the custom membership function to the Rule Viewer, and is now available for creating rules
for the fuzzy inference process. To view the custom function in the Rule Viewer, select Edit > Rules in either the
FIS Editor or the Membership Function Editor.
28/7/2558 12:09
6 of 8
jar:file:///C:/Program%20Files/MATLAB/R2011a/help/toolbox/fuzzy/hel...
6. To add custom membership functions for output1, select it in the Membership Function Editor, and repeat steps 4
and 5.
Back to Top
28/7/2558 12:09
7 of 8
jar:file:///C:/Program%20Files/MATLAB/R2011a/help/toolbox/fuzzy/hel...
For a matrix x, min(x) returns a row vector containing the minimum element from each column.
x=[1 2 3 4;5 6 7 8;9 10 11 12];
min(x)
ans =
1
2
3
4
For N-D arrays, min(x) operates along the first non-singleton dimension.
The function min(x,y) returns an array that is same size as x and y with the minimum elements from x or y. Either of
the input arguments can be a scalar. Functions such as max, and prod operate in a similar manner.
In the toolbox, the AND implication methods perform an element by element matrix operation, similar to the MATLAB
function min(x,y).
a=[1 2; 3
b=[2 2; 2
min(a,b)
ans =
1
2
4];
2];
2
2
The OR implication methods perform an element by element matrix operation, similar to the MATLAB function max(x,y).
outputmf is an nr-by-ns matrix and contains the data for each output membership function, where the i row is the data for
th
the i output membership function.
The following is an example of a custom implication function:
function impfun = custom_imp(w,outputmf)
impfun = min(w,outputmf);
28/7/2558 12:09
8 of 8
jar:file:///C:/Program%20Files/MATLAB/R2011a/help/toolbox/fuzzy/hel...
After you create and save a custom inference function, use the following steps to specify the function in the fuzzy
inference process:
1. In the lower-left panel of the FIS Editor, select Custom from the drop-down menu corresponding to the inference
method for which you want to specify the custom function.
This action opens a dialog box where you specify the name of the custom inference function.
2. In the Method name field, specify the name of the custom inference function, and click OK.
The custom function replaces the built-in function when building the fuzzy inference system.
3. To specify custom functions for other inference methods, repeat steps 1 and 2.
Back to Top
Was this topic helpful?
Terms of Use
Patents
Yes
No
Trademarks
Acknowledgments
28/7/2558 12:09