Main Content

Define Fuzzy Rules Using Fuzzy Logic Designer

Since R2022b

Once you create a fuzzy inference system (FIS) using Fuzzy Logic Designer and define the input and output variables along with their respective membership functions, you can create a fuzzy rule base for your system.

Each if-then rule in a fuzzy system has two components.

  • Antecedent — The if portion of the rule, which specifies the input variable linguistic terms

  • Consequent — The then portion of the rule, which specifies the output variable linguistic terms

For more information on fuzzy rule structure, see Foundations of Fuzzy Logic.

Once you define your rules, you can analyze the behavior of your FIS, including the rule inference process. For more information, see Analyze Fuzzy System Using Fuzzy Logic Designer.

Add Rules

To add a rule to your FIS, first open the Rule Editor document.

Rule Editor with no rules currently listed in the table. There is a plus icon on the right edge of the Rule Editor near the top of the rule table

To add a rule, click the plus icon. The app adds a default rule to the rule table and shows the rule properties in the Property Editor. You can then edit the rule properties using the Property Editor.

On the left, the Rule Editor lists one new rule selected in the rule table. On the right, the Property Editor shows the default properties for the new rule.

You can copy an existing rule by selecting the rule in the Rule Editor and clicking the copy icon.

You can also add a rule by selecting either the FIS name or Rules in the System Browser. Then, on the Design tab, in the Add Components gallery, click Rule.

App toolstrip with the Rule option highlighted as the first option in the Add Components gallery

Add All Possible Rules

You can add AND-based rules to your FIS for all possible input combinations using one of the following methods:

  • In the Rule Editor, click Add All Possible Rules.

    Rule Editor showing the Add All Possible Rules button on the left immediately above the rule table

  • Select the FIS name or Rules in the System Browser. Then, in the Add Components gallery, click Add All Rules.

    App toolstrip with the Add All Rules option highlighted as the second option in the Add Components gallery

Edit Rules

To configure a rule, first select the rule in the System Browser or the Rule Editor, which displays the rule in the Property Editor.

Property Editor for configuring rules. The top section lists the Name, Weight, and Connection parameters. Below that, the If section shows two drop-down menus for each input variable. At the bottom, the Then section shows two drop-down menus for each output variable.

To define the rule antecedent, first specify the connection operator. To do so, set the Connection parameter to one of the following values.

  • And — Connect the input linguistic terms using an AND operation.

  • Or — Connect the input linguistic terms using an OR operation.

Then, under If, select a linguistic term for each input variable. To do so, in the right-hand drop-down list, select a membership function name. To ignore an input variable, select none.

Then, indicate whether to apply a NOT operation to the selected membership function. To apply a NOT operation, in the left-hand drop-down list, select is not. Otherwise, select is.

Similarly, under Then configure each output variable in the consequent.

Typically, you weight the importance of all the rules in a FIS equally. However, you can decrease the relative weighting of a rule. To do so, specify a value for the Weight parameter that is less than 1.

Delete Rules

To delete a rule from your FIS, in the Rule Editor, select the rule and click the trash icon

Alternatively, in the System Browser, under Rules, right-click the rule and select Delete.

System Browser showing the right-click menu for a rule. The cursor is pointing to the Delete menu item.

To delete all of the rules from your FIS, in the Rule Editor, click Clear All Rules.

Rule Editor showing the Clear All Rules button on the right immediately above the rule table

Alternatively, in the System Browser, right-click Rules, and select Delete all rules.

System Browser showing the right-click menu for the Rules entry. The cursor is pointing to the Delete all rules menu item.

See Also

Related Topics