You are on page 1of 11

Cpe521: APPLIED FUZZY LOGIC

Instructor: Dr. Powsiri Klinkhachorn

Assignment # II
Fuzzy Toolbox

Submitted By:
Ajit Kumar Pandey
apandey@mix.wvu.edu
700 59 4785

FUZZY TOOLBOX
Matlab is used for implementing fuzzy relations and sets. The Matlab toolbox and
simulink helps the user to view the real time simulations and how the fuzzy logic works
and can be applied for different fields.
The inbuilt fuzzy logic toolbox will pop up when you type fuzzy at the command prompt.
This toolbox has been developed in the Matlab using some predefined basic functions
using the Matlabs GUI (Graphical User Interface). We can shape the toolbox as required
with user defined functions. This project deals a particular application. When the user
possesses the rough idea of what should be the value of input1 and Input2, the toolbox
will calculate the value of output based on those values.
Overview:
The toolbox designed may not be as good as the inbuilt fuzzy tipper, but this is
an attempt to get the best results using some programming fundamentals and user defined
functions. The toolbox is names as fuzzytool1. The toolbox provides user to define the
range of the input membership functions and the output membership functions. This
toolbox has two inputs and a single output. The rules used are defined in ft3. In the
rules window the input and output membership functions are displayed. The membership
function used here is triangle. In most of the applications the triangle membership
function is well suited for the purpose and provides satisfactory results.
The user can define the input1 and input2 values and check the output value and
membership function from the rule window. This method is universally accepted as the
best one and proved to be giving consistent results. The user can check the value and
membership function for both AND & OR methods. The AND method works as min
function and OR works as max function. The clipping method is used in the design
process for obtaining output.

The Fuzzy tool window:

Fig. 1
The Fig. 1 shows the, main window when fuzzy tool box is started by typing Fuzzytool1 at the
Matlab prompt (>>). It displays the type of membership functions used for the two inputs viz.
Input1 & Input2 which is triangular in both the cases. Moreover the Type of membership function
used for representing the output is also triangular.
If we click on the axes background of Input1, Input2, or Output we can open the window showing
their characteristics membership functions and a window showing IF -Then Rules for FIS
Mamdani.

The AND Method uses Min. Function, OR method uses Max. Function, implication uses Min.
Function and the type of Defuzzification used is cantroid.

By clicking on the back ground of axes labeled input1 or input2 we can open a window ft2 that
looks like this:

Fig. 2
ft2 basically shows Membership functions of inputs and output. In both the cases, the type of
membership function used is Triangular that can be seen in the MF Plots axis by clicking on input
or output push buttons at the top left of the ft2 window (Fig.2).
The two panels in the same window display the properties of the variables selected.

Fig. 3
We can change the value of the parameters used to draw any of the three triangles in the
corresponding edit boxes. When we press input or output buttons the changes can viewed in the
display window (Fig. 4).

After changing value in any of the edit boxes press input buttons or output button, the plot will
change itself accordingly as shown in Fig. 4

Fig. 4
We can see in Fig. 4 that after changing the value of the parameters in the second edit box from
7.5 to 8 directly into the edit box the green colored triangle changes accordingly. We need to press
any of the push buttons labeled input1, input2, and output on the top left of the window
before toolbox can implement any change in the plot.
The Show Rules button when pressed opens a window shown in Fig. 5 that contains the IF-THEN
rules and the close button closes the window.

Rules Window:

Fig. 5
The Fig. 5 shows the rules window that display all the rules used by the Fuzzy Inferences Set to
come to the desired output. It provides options for Input1 and Input2 and we can set the output
based on the two inputs using pop-up menus. It also provides options to choose from AND/OR
methods using Radio buttons. We can select only one option from the two conjunctions.
The bottom of the window in Fig. 5 shows FIS Name and a close button that closes the window
and we return back to the FIS Mamdani window.

The menu items can be used to switch to other windows in the whole application.
The File menu provides options like New FIS, Exit and the Edit provides options like Rules,
Membership functions, etc. Last menu item View provides options like View Rules and surface.
For example, if we select Rules in the view menu, the toolbox opens f4 window that looks like
what is shown in Fig. 6

The f4 window:

Fig. 6
Fig. 6 shows the main output window where we can view analyze and verify the input and output
plots. There are three inputs under the label input1 & input2 and three outputs under the label
output. The fourth plot under the output label provides the defuzzified output plot. This plot is
used to calculate the final value of output variable.
We have the same items in the menu as in previous windows and one inputs edit box where we
can select and change input variables. The default value of input1 is 4 and for input2 it is 7. We
can anytime change these values as per our rules.
When we press the Plot pushbutton at the bottom of the window, we can see the plots of the
membership functions of the two inputs and the output. The last plot displays the defuzzified
output from where we can obtain the value of output.

The close button closes all the windows.


The Fig. 7 makes everything clear.

Fig. 7
If we want to switch back to the main window i.e. Fuzzytool1 window (Fig. 1) then we can select
New FIS option from the file menu of this window or we can select Exit to close all the windows
and return to Matlab.

Important Conclusions:

This Fuzzy tool is developed using the IDE feature of the MATLAB version 7.0. It demonstrates
some basic features of a Fuzzy tool box and triangular Membership function is being used to
imitate the Fuzzy tipper included in the Matlab Software. It can be used for two different inputs to
obtain one output. It provides options for two Fuzzy Inference Systems viz. Mamdani and Sugeno
that can be selected from File menu of any windows of the application.
Shortcomings: This Tool requires that the user must have the knowledge of how to plot the
membership functions, like Triangular MF for Input1 or output, when to select Rules option from
the edit menu and when press close buttons without which he may get the erroneous results or he
may close the application before he can see the output plots. Finally, the Fuzzy tool provides the
user to work with the basic ideas of the fuzzy inference systems.

Reference books and Websites:


Books referred:

MATLAB: Language of Technical Computing.


The Math Works Inc.
Getting started with MATLAB
Rudra Pratap.

Websites:
http://www.math.utah.edu/lab/ms/matlab/matlab.html
Provides link for basic tutorials relating mathematical calculations in Matlab.
http://www.math.ufl.edu/help/matlab-tutorial/matlab-tutorial.html#SEC5
http://www.math.siu.edu/matlab/tutorial2.pdf
This link gives access to Matlab programming, M-files, and Graphs Plotting.
*******************************END******************************

You might also like