Fuzzy Logic Toolbox | ![]() ![]() |
Building Your Own Fuzzy Simulink Models
To build your own Simulink systems that use fuzzy logic, simply copy the Fuzzy Logic Controller block out of sltank
(or any of the other Simulink demo systems available with the toolbox) and place it in your own block diagram. You can also find the Fuzzy Logic Controller block in the Fuzzy Logic Toolbox library, which you can open either by selecting Fuzzy Logic Toolbox in the Simulink Library Browser, or by typing
The following library appears.
The Fuzzy Logic Toolbox library contains the Fuzzy Logic Controller and Fuzzy Logic Controller with Rule Viewer blocks. It also includes a Membership Functions sublibrary that contains Simulink blocks for the built-in membership functions.
The Fuzzy Logic Controller with Rule Viewer block is an extension of the Fuzzy Logic Controller block. It allows you to visualize how rules are fired during simulation. Double-click the Fuzzy Controller With Rule Viewer block, and the following appears.
To initialize the Fuzzy Logic Controller blocks (with or without the Rule Viewer), double-click on the block and enter the name of the structure variable describing your FIS. This variable must be located in the MATLAB workspace.
About the Fuzzy Logic Controller Block
For most fuzzy inference systems, the Fuzzy Logic Controller block automatically generates a hierarchical block diagram representation of your FIS. This automatic model generation ability is called the Fuzzy Wizard. The block diagram representation only uses built-in Simulink blocks and therefore allows for efficient code generation. For more information about the Fuzzy Logic Controller block, see fuzblock
.
The Fuzzy Wizard cannot handle FIS with custom membership functions or with AND, OR, IMP, and AGG functions outside of the following list:
In these cases, the Fuzzy Logic Controller block uses the S-function sffis
to simulate the FIS. For more information, see sffis
.
Example: Cart and Pole Simulation
The cart and pole simulation is an example of an FIS model auto-generated by the Fuzzy Logic Controller block. Type
at the MATLAB prompt to open the simulation.
Right-click on the Fuzzy Logic Controller block and select Look under mask
from the right-click menu. This subsystem opens.
Follow the same procedure to look under the mask of the FIS Wizard subsystem to see the implementation of your FIS. This following figure shows part of the implementation (the entire model is too large to show in this document).
As the figure shows, the Fuzzy Logic Controller block uses built-in Simulink blocks to implement your FIS. Although the models can grow complex, this representation is better suited than the S-function sffis
for efficient code generation.
![]() | An Example: Water Level Control | Sugeno-Type Fuzzy Inference | ![]() |