Fuzzy Logic Toolbox    

Customizing Your Fuzzy System

If you want to include customized functions as part of your use of the Fuzzy Logic Toolbox, you must follow a few guidelines. You may substitute customized functions for the AND, OR, aggregation, and defuzzification methods, provided your customized functions work in a similar way to max, min, or prod in MATLAB. That is, they must be able to operate down the columns of a matrix.

In MATLAB, for a matrix x, min(x) returns a row vector containing the minimum element from each column. For N-D arrays, min(x) operates along the first non-singleton dimension. The function min(x,y), on the other hand, returns an array the same size as x and y populated with the smallest elements from x or y. Either one can be a scalar. Functions such as max, prod, and mean operate in a similar manner.

In the Fuzzy Logic Toolbox, the implication method performs an element by element matrix operation, similar to the min(x,y) function in MATLAB, as in

After you have defined your custom function using the procedure described in the next section, use the FIS Editor to substitute your custom function for a standard function. To do this,

  1. Open the FIS Editor by typing fuzzy at the command line prompt.
  2. In the lower left panel, locate the method you want to replace.
  3. In the drop-down menu, click Custom. A dialog box appears.
  4. Enter the name of your custom function and click OK.

Your custom function then replaces the standard function in all subsequent operations.

Custom Membership Functions

You can create your own membership functions using an M-file. The values these functions can take must be between 0 and 1. There is a limitation on customized membership functions in that they cannot use more than 16 parameters.

To define a custom membership function named custmf

  1. Create an M-file for a function, custmf.m, that takes values between 0 and 1, and depends on 16 parameters at most.
  2. Choose the Add Custom MF item in the Edit menu on the Membership Function Editor GUI.
  3. Enter your custom membership function M-file name, custmf, in the M-file function name text box.
  4. Enter the vector of parameters you want to use to parameterize your customized membership function in the text box next to Parameter list.
  5. Give the custom membership function a name different from any other membership function name you will use in your FIS.
  6. Click OK.

Here is some sample code for a custom membership function, testmf1, that depends on eight parameters between 0 and 10.

You can try naming this file testmf1.m and loading it into the Membership Function Editor using the parameters of your choice.


  Importing and Exporting from the GUI Tools Working from the Command Line