Fuzzy Logic Toolbox    

The Rule Editor


Constructing rules using the graphical Rule Editor interface is fairly self-evident. Based on the descriptions of the input and output variables defined with the FIS Editor, the Rule Editor allows you to construct the rule statements automatically, by clicking on and selecting one item in each input variable box, one item in each output box, and one connection item. Choosing none as one of the variable qualities will exclude that variable from a given rule. Choosing not under any variable name will negate the associated quality. Rules may be changed, deleted, or added, by clicking on the appropriate button.

The Rule Editor also has some familiar landmarks, similar to those in the FIS Editor and the Membership Function Editor, including the menu bar and the status line. The Format pop-up menu is available from the Options pull-down menu from the top menu bar -- this is used to set the format for the display. Similarly, Language can be set from under Options as well. The Help button will bring up a MATLAB Help window.

To insert the first rule in the Rule Editor, select the following:

The resulting rule is

The numbers in the parentheses represent weights that can be applied to each rule if desired. You can specify the weights by typing in a desired number between zero and one under the Weight setting. If you do not specify them, the weights are assumed to be unity (1).

Follow a similar procedure to insert the second and third rules in the Rule Editor to get

To change a rule, first click on the rule to be changed. Next make the desired changes to that rule, and then click on Change rule. For example, to change the first rule to

click not under each variable, and then click Change rule.

The Format pop-up menu from the Options menu indicates that you're looking at the verbose form of the rules. Try changing it to symbolic. You will see

There is not much difference in the display really, but it's slightly more language neutral, since it doesn't depend on terms like "if" and "then." If you change the format to indexed, you'll see an extremely compressed version of the rules that has squeezed all the language out.

This is the version that the machine deals with. The first column in this structure corresponds to the input variable, the second column corresponds to the output variable, the third column displays the weight applied to each rule, and the fourth column is shorthand that indicates whether this is an OR (2) rule or an AND (1) rule. The numbers in the first two columns refer to the index number of the membership function. A literal interpretation of rule 1 is: "If input 1 is MF1 (the first membership function associated with input 1) then output 1 should be MF1 (the first membership function associated with output 1) with the weight 1." Since there is only one input for this system, the AND connective implied by the 1 in the last column is of no consequence.

The symbolic format doesn't bother with the terms, if, then, and so on. The indexed format doesn't even bother with the names of your variables. Obviously the functionality of your system doesn't depend on how well you have named your variables and membership functions. The whole point of naming variables descriptively is, as always, making the system easier for you to interpret. Thus, unless you have some special purpose in mind, it will probably be easier for you to stick with the verbose format.

At this point, the fuzzy inference system has been completely defined, in that the variables, membership functions, and the rules necessary to calculate tips are in place. It would be nice, at this point, to look at a fuzzy inference diagram like the one presented at the end of the previous section and verify that everything is behaving the way we think it should. This is exactly the purpose of the Rule Viewer, the next of the GUI tools we'll look at. From the View menu, select View rules....


  The Membership Function Editor The Rule Viewer