Newsletters - MATLAB News & Notes
A complete toolset for building a fuzzy logic control system
By Kelly Liu
The Fuzzy Logic Toolbox provides an integrated computational environment for the development of a control system using fuzzy logic. In combination with MATLAB 5 and Simulink 2, the Fuzzy Logic Toolbox provides an effective solution to many previously intractable problems in fuzzy-control applications.
In version 2.0 of the toolbox, you can build, analyze, tune, and simulate a fuzzy logic system completely from within a GUI. Using this GUI, you can also adjust the parameters of a user-defined fuzzy logic system to fit explicit or implicit specifications (because the system is able to "learn" from empirical data).
The Fuzzy Logic Toolbox in action
Suppose we are trying to control the flow of cars merging onto a highway by controlling a traffic light in front of the merging lane with fuzzy logic.
The goal is to sequence the traffic light changes so as to optimize traffic flow. A fuzzy logic controller can use the time of day as well as the highway traffic-load variable to obtain a more stable traffic control for the merging lane.
We will build our fuzzy controller using only the GUI of Fuzzy Logic 2.0. This procedure involves three major steps: building, training, and simulating.
Building the Fuzzy Logic System
We will be working with the Fuzzy Logic System Editors. All operations, including changes to membership functions, fuzzy rules, output evaluation, and surface viewing, are carried out using the mouse.
Here are the fuzzy rules for our traffic signal control example.- If highway traffic is heavy, then red-light time is long
- If highway traffic is light, then red-light time is short
- If time is morning, then red-light time is long
The control system that we have built is based on common knowledge and expressed in conventional English. The Fuzzy Logic Toolbox converts our rules and membership functions into a complete fuzzy control system.
![]() |
| The Fuzzy Logic Toolbox Rule Editor. In version 2.0, you can compose the fuzzy logic rules by making selections from list boxes. |
Training
We can modify the parameters of our membership functions when empirical data is available. Let's suppose we have data on highway traffic flow and on the control commands of a police officer. Using the Fuzzy Logic Toolbox, we can "train" the fuzzy logic system to adjust itself according to what it "learns" from the police officer's commands.
The theoretical basis for training from data is the Adaptive Fuzzy Neural Inference System (ANFIS) algorithm, which is supplied with the toolbox. To use the ANFIS algorithm from the ANFIS editor (a new GUI in this version)
- Load the training data by clicking on the Load Data button in the ANFIS Editor.
- Select a training algorithm from the Train FIS block's pop-up menu and set the error tolerance and training epoch.
- Train the fuzzy logic system by pressing the Train Now button.
- Test the trained system by pressing the Test Now button.
Simulating
We can use Simulink to simulate our fuzzy logic traffic control model. Within the Rule Viewer of Fuzzy Logic 2.0, we can observe each fuzzy logic rule as it is triggered during simulation. We can then modify the fuzzy logic controller based on the results of the simulation using the Rule Editor, the Membership Function Editor, or the ANFIS Editor, and save the adjusted fuzzy logic controller to the workspace. When we rerun the simulation, we can study the effects of our modifications to the fuzzy logic controller.
![]() |
|
The ANFIS Editor, showing the error rate dropping on the learning curve of the fuzzy logic traffic control system.
|
A free data sheet describing the Fuzzy Logic Toolbox is available.


