Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 44

CERTIFICATE

Certified that Mr. Varun Kumar Kadian,Vaibhav Chabbra,Umesh Kumar and


Vaibhav Gaur , students of semester 4th of ICE NSIT , has undertaken the
project work on “FUZZYLOGIC” under the supervision of Ms. Deepali Sharma
as per requirement stipulated in the course curriculum. The performance of student
has been satisfactory.

Deepali Sharma

(Project Incharge)
ACKNOWLEDGEMENT
The project work on “FUZZYLOGIC” was carried out at NSIT , under guidance
of Ms. Deepali Sharma. We gratefully acknowledge the guidance of our project
incharge for the successful completion of the project. The support of Head of
Department, Director/Principal, faculty and the laboratory staff in execution of
project is gratefully acknowledged.

Varun Kumar Kadian(524/IC/09)

Vaibhav Chhabra(521/IC/09)

Umesh Kumar(520/IC/09)

Vaibhav Gaur(522/IC/09)
MODULE – 1
Introduction to MATLAB
Etymology: MATLAB stands for Matrix Laboratory. The reason behind this is that internally,
every computation done by this application is in the form of number matrices of n-dimensions.
Hence, the name.

As it has already been touched in the Preface section, MATLAB is an engineering utility
application which allows us to compute many kinds of problems of different fields of science
and technology. This is a virtual environment which allows us to do numerical computations in a
simplified manner. Developed by Mathworks, this allows matrix manipulations, function
plotting, algorithm implementations and creation of Graphical User Interfaces. This designed for
live interaction with other computer language programs like C++ and FORTRAN.

Many extensions are used for MATLAB files like

.fig : MATLAB Figure


.m  : MATLAB function, script, or class
.mat  : MATLAB binary file for storing variables
.mex : MATLAB executable (platform specific, e.g. ".mexmac" for the Mac.)
.jkt  : GPU Cache file generated by Jacket for MATLAB (AccelerEyes)
.mum : MATLAB CAPE-OPEN Unit Operation Model File (AmsterCHEM)
In this project we will be using .m as extension for M-file.

MATLAB can call functions and subroutines written in the C programming language or Fortran.
A wrapper function is created allowing MATLAB data types to be passed and returned. The
dynamically loadable object files created by compiling such functions are termed "MEX-files"
(for MATLAB executable).

MATLAB has several functions:

eig(A) : to find Eigen values of matrix A

inv(A) : to find inverse of matrix A


pzmap(A) : to find pole zero mapping of transfer function A

plot(X,Y) : to plot a 2-D graph between X and Y

MATLAB is a "Matrix Laboratory", and as such it provides many convenient ways for creating
vectors, matrices, and multi-dimensional arrays. In the MATLAB vernacular, a vector refers to a
one dimensional (1×N or N×1) matrix, commonly referred to as an array in other programming
languages. A matrix generally refers to a 2-dimensional array, i.e. an m×n array where m and n
are greater than or equal to 1. Arrays with more than two dimensions are referred to as
multidimensional arrays. We can define vectors and matrices using square bracket, space and
semicolon in MATLAB.

Utilities
MATAB as an application is so extremely useful, that it can be used to do almost anything.
Starting from solving of nth order set of equations, it can be used in aeronautics, predicting
market statistics and economic situations, in wavelet transformations, as well as genetic
mapping. This application nowadays is being used in every research based industry to its benefit.
In 2004, MATLAB had around one million users across industry and academia.

History
MATLAB was created in the late 1970s by Cleve Moler, the chairman of the
computer department at the University of New Mexico. He designed it to give his students access
to LINPACK and EISPACK without having to learn Fortran. It soon spread to other universities
and found a strong audience within the applied mathematics community. Jack Little, an engineer,
was exposed to it during a visit Moler made to Stanford University in 1983. Recognizing its
commercial potential, he joined with Moler and Steve Bangert. They rewrote MATLAB in C and
founded MathWorks in 1984 to continue its development. These rewritten libraries were known
as JACKPAC. In 2000, MATLAB was rewritten to use a newer set of libraries for matrix
manipulation, LAPACK. MATLAB was first adopted by control design engineers, Little's
specialty, but quickly spread to many other domains. It is now also used in education, in
particular the teaching of linear algebra and numerical analysis, and is popular amongst scientists
involved with image processing.

Toolboxes
A MATLAB user is always empowered with strikingly efficient and diverse set of user-friendly
toolboxes which make the job of the programmer very simple by interacting graphically and
producing vivid diagrammatic results. These toolboxes may be used together to solve complex
problems.

The toolboxes available in the version used through this training are:

1. Aerospace Toolbox
The Aerospace Toolbox product extends the MATLAB ® technical computing
environment by providing reference standards, environment models, and aerodynamic
coefficient importing for performing advanced aerospace analysis to develop and
evaluate your designs. The toolbox provides the following to enable you to visualize
flight data in a three-dimensional environment and reconstruct behavioral anomalies in
flight-test results:
 Aero.Animation, Aero.Body, Aero.Camera, and Aero.Geometry objects and associated
methods
 An interface to the FlightGear flight simulator
 An interface to the Simulink® 3D Animation™ software

2. Bioinformatics Toolbox
The Bioinformatics Toolbox™ product extends the MATLAB® environment to provide
an integrated software environment for genome and proteome analysis. Scientists and
engineers can answer questions, solve problems, prototype new algorithms, and build
applications for drug discovery and design, genetic engineering, and biological research.
An introduction to these features will help you to develop a conceptual model for
working with the toolbox and your biological data.
Toolbox features and functions fall within these categories:
 Data formats and databases — Connect to Web-accessible databases containing
genomic and proteomic data. Read and convert between multiple data formats.
 Sequence analysis — Determine the statistical characteristics of a sequence, align
two sequences, and multiply align several sequences. Model patterns in biological
sequences using hidden Markov model (HMM) profiles.
 Phylogenetic analysis — Create and manipulate phylogenetic tree data.
 Microarray data analysis — Read, normalize, and visualize microarray data.
 Mass spectrometry data analysis — Analyze and enhance raw mass spectrometry
data.
 Statistical learning — Classify and identify features in data sets with statistical
learning tools.
 Programming interface — Use other bioinformatic software (BioPerl and
BioJava) within the MATLAB environment.

3. Communications Toolbox
Communications Toolbox software extends the MATLAB technical computing
environment with functions, plots, and a graphical user interface for exploring, designing,
analyzing, and simulating algorithms for the physical layer of communication systems.
The toolbox helps you create algorithms for commercial and defense wireless or wireline
systems.
The key features of the toolbox are:
 Functions for designing the physical layer of communications links, including source
coding, channel coding, interleaving, modulation, channel models, and equalization
 Plots such as eye diagrams and constellations for visualizing communications signals
 Graphical user interface for comparing the bit error rate of your system with a wide
variety of proven analytical results
 Galois field data type for building communications algorithms

4. Control System Toolbox


The Control System Toolbox™ product extends the MATLAB® software to provide
functions designed specifically for control engineering.
This toolbox lets you construct and analyze linear models of dynamic systems. Use
Control System Toolbox functions to model dynamic systems as transfer functions, in
state-space form, or as arrays of frequency response data. Plot the time and frequency
responses of your system to understand how your system behaves.
You can also use the toolbox to design and tune single-loop or multiple-loop control
systems using various classical and state-space techniques.

5. Curve Fitting Toolbox


Curve Fitting Toolbox™ software is a collection of graphical user interfaces (GUIs) and
M-file functions for curve and surface fitting that operate in the MATLAB ® technical
computing environment. The toolbox supplements MATLAB features with:
 Data preprocessing capabilities, such as sectioning, excluding data, and smoothing
 Data fitting using parametric and nonparametric models:
o The toolbox includes a library of parametric models, with polynomials,
exponentials, rationals, sums of Gaussians, Fourier polynomials, and many others.
o You can also define custom models to precisely reflect the goals of your data
analysis.
o Nonparametric models are available through a variety of smoothers and
interpolants.
 Fitting methods for linear least squares, nonlinear least squares, weighted least squares,
constrained least squares, and robust fitting are available
 Data and fit statistics to assist you in analyzing your models
 Postprocessing capabilities that allow you to interpolate, extrapolate, differentiate, and
integrate the fit
 The ability to save your work in various formats, including workspace variables, binary
files, and automatically generated MATLAB code

6. Data Acquisition Toolbox


Data Acquisition Toolbox™ software is a collection of M-file functions and a MEX-file
(shared library) built on the MATLAB® technical computing environment. The toolbox
also includes several dynamic link libraries (DLLs) called adaptors, which enable you to
interface with specific hardware. The toolbox provides you with these main features:
 A framework for bringing live, measured data into the MATLAB workspace using PC-
compatible, plug-in data acquisition hardware
 Support for analog input (AI), analog output (AO), and digital I/O (DIO) subsystems
including simultaneous analog I/O conversions
 Support for these popular hardware vendors/devices:
o Advantech® boards that use the Advantech Device Manager
o Measurement Computing™ Corporation (ComputerBoards) boards
o National Instruments® boards that use Traditional NI-DAQ or NI-DAQmx
software

7. Database Toolbox
The Database Toolbox™ software is one of an extensive collection of toolboxes for use
with the MATLAB® product. This toolbox enables you to use MATLAB functions to
import and export data between the MATLAB workspace and relational databases. With
the Database Toolbox software, you can bring data from a database into the MATLAB
workspace, and then use MATLAB computational and analytic tools to work with the
data, You can then store the results back in the database or in another database.

8. Datafeed Toolbox
This toolbox, used with the MATLAB ® product, effectively turns your MATLAB
workstation into a financial data acquisition terminal. The toolbox enables you to:
 Retrieve and analyze a wide variety of security data from financial data servers in
MATLAB.
 Access market, time-series, and historical market data in MATLAB.
 Monitor the status and history of each connection to a supported data service provider.
 Fetch data fields for multiple securities in a single call.
 Look up security ticker symbols from the toolbox GUI or the MATLAB command line.

9. Econometric Toolbox
The Econometrics Toolbox™ software, combined with MATLAB ®, Optimization
Toolbox™, and Statistics Toolbox™ software, provides an integrated computing
environment for modeling and analyzing economic and social systems. It enables
economists, quantitative analysts, and social scientists to perform rigorous modeling,
simulation, calibration, identification, and forecasting with a variety of standard
econometrics tools.
Specific functionality includes:
 Univariate ARMAX/GARCH composite models with several GARCH variants
(ARCH/GARCH, EGARCH, and GJR)
 Dickey-Fuller and Phillips-Perron unit root tests
 Multivariate VARX model estimation, simulation, and forecasting
 Multivariate VARMAX model simulation and forecasting
 Monte Carlo simulation of many common stochastic differential equations (SDEs),
including arithmetic and geometric Brownian motion, Constant Elasticity of Variance
(CEV), Cox-Ingersoll-Ross (CIR), Hull-White, Vasicek, and Heston stochastic volatility
 Monte Carlo simulation support for virtually any linear or nonlinear SDE
 Hodrick-Prescott filter
 Statistical tests such as likelihood ratio, Engle's ARCH, Ljung-Box Q
 Diagnostic tools such as Akaike information criterion (AIC), Bayesian information
criterion (BIC), and partial/auto/cross correlation functions

10. Filter Design Toolbox


Filter Design Toolbox™ software is a collection of tools that provides advanced
techniques for designing, simulating, and analyzing digital filters. It extends the
capabilities of Signal Processing Toolbox™ software with filter architectures and design
methods for complex real-time DSP applications, including adaptive filtering and
multirate filtering, as well as filter transformations.

11. Financial Toolbox


The MATLAB® and Financial Toolbox™ products provide a complete integrated
computing environment for financial analysis and engineering. The toolbox has
everything you need to perform mathematical and statistical analysis of financial data and
display the results with presentation-quality graphics. You can quickly ask, visualize, and
answer complicated questions.
In traditional or spreadsheet programming, you must deal with all sorts of housekeeping
details: declaring, data typing, sizing, and so on. MATLAB software does all that for you.
You just write expressions the way you think of problems. There is no need to switch
tools, convert files, or rewrite applications.

12. Financial Derivatives Toolbox


Financial Derivatives Toolbox™ software provides components for analyzing individual
derivative instruments and portfolios containing several types of interest-rate-based and
equity-based financial instruments.

13. Fuzzy Logic Toolbox


Fuzzy Logic Toolbox™ software is a collection of functions built on the MATLAB ®
technical computing environment. It provides tools for you to create and edit fuzzy
inference systems within the framework of MATLAB. You can also integrate your fuzzy
systems into simulations with Simulink ® software. You can even build stand-alone C
programs that call on fuzzy systems you build with MATLAB. This toolbox relies
heavily on graphical user interface (GUI) tools to help you accomplish your work,
although you can work entirely from the command line if you prefer.

14. Genetic Algorithm and Direct Search Toolbox


Genetic Algorithm and Direct Search Toolbox functions extend the capabilities of
Optimization Toolbox™ software and the MATLAB ® numeric computing environment.
They include routines for solving optimization problems using
 Direct search
 Genetic algorithm
 Simulated annealing
These algorithms enable you to solve a variety of optimization problems that lie outside
the scope of Optimization Toolbox solvers.

15. Image Acquisition Toolbox


The Image Acquisition Toolbox software is a collection of functions that extend the
capability of the MATLAB® numeric computing environment. The toolbox supports a
wide range of image acquisition operations, including:
 Acquiring images through many types of image acquisition devices, from professional
grade frame grabbers to USB-based webcams
 Viewing a preview of the live video stream
 Triggering acquisitions (includes external hardware triggers)
 Configuring callback functions that execute when certain events occur
 Bringing the image data into the MATLAB workspace

16. Image Processing Toolbox


The Image Processing Toolbox software is a collection of functions that extend the
capability of the MATLAB numeric computing environment. The toolbox supports a
wide range of image processing operations, including
 Spatial image transformations
 Morphological operations
 Neighborhood and block operations
 Linear filtering and filter design
 Transforms
 Image analysis and enhancement
 Image registration
 Deblurring
 Region of interest operations

17. Instrument Control Toolbox


Instrument Control Toolbox™ software is a collection of M-file functions built on the
MATLAB® technical computing environment. The toolbox provides you with these
features:
 A framework for communicating with instruments that support the GPIB interface
(IEEE®-488), the VISA standard, and the TCP/IP and UDP protocols. Note that the
toolbox extends the basic serial port features included with the MATLAB software.
 Support for IVI, VXI plug&play, and MATLAB instrument drivers.
 Functions for transferring data between the MATLAB workspace and your instrument:
o The data can be binary (numerical) or text.
o The transfer can be synchronous and block access to the MATLAB Command
Window, or asynchronous and allow access to the MATLAB Command Window.
 Event-based communication.
 Functions for recording data and event information to a text file.
 Tools that facilitate instrument control in an easy-to-use graphical environment.

18. Mapping Toolbox


The Mapping Toolbox™ product comprises an extensive set of functions and graphical
user interfaces (GUIs) for creating map displays and analyzing and manipulating
geospatial data in the MATLAB environment. You can create maps that combine
different types of data from multiple sources and display them in their correct spatial
relationships. The toolbox supports spatial analysis methods such as line-of-sight
calculations on terrain data and geographic computations that account for the curvature of
the Earth's surface. Its library of map projections and georeferencing utilities give you
precise control over projected and unprojected coordinate systems.

19. Model Predictive Control Toolbox


The Model Predictive Control Toolbox™ product is a collection of software that helps
you design, analyze, and implement an advanced industrial automation algorithm. Like
other MATLAB® tools, it provides a convenient graphical user interface (GUI) as well as
a flexible command syntax that supports customization.

20. Neural Network Toolbox


Neural networks are composed of simple elements operating in parallel. These elements
are inspired by biological nervous systems. As in nature, the connections between
elements largely determine the network function. You can train a neural network to
perform a particular function by adjusting the values of the connections (weights)
between elements.

21. OPC Toolbox


OPC Toolbox™ software is a collection of functions that extend the capability of the
MATLAB® environment, and blocks that extend the Simulink® simulation environment.
Using OPC Toolbox functions and blocks, you can acquire live OPC data directly into
MATLAB and Simulink, and write data directly to the OPC server from MATLAB and
Simulink.

22. Optimization Toolbox


Optimization Toolbox software extends the capability of the MATLAB ® numeric
computing environment. The software includes functions for many types of optimization
including
 Unconstrained nonlinear minimization
 Constrained nonlinear minimization, including semi-infinite minimization problems
 Quadratic and linear programming
 Nonlinear least-squares and curve fitting
 Constrained linear least squares
 Sparse and structured large-scale problems, including linear programming and
constrained nonlinear minimization
 Multiobjective optimization, including goal attainment problems and minimax problems
The toolbox also includes functions for solving nonlinear systems of equations.

23. Parallel Computing Toolbox


Parallel Computing Toolbox™ software allows you to offload work from one MATLAB®
session (the client) to other MATLAB sessions, called workers. You can use multiple
workers to take advantage of parallel processing. You can use a local worker to keep your
MATLAB client session free for interactive work, or with MATLAB ® Distributed
Computing Server™ you can take advantage of another computer's speed.

24. Partial Differential Equation Toolbox


The objectives of Partial Differential Equation Toolbox™ software are to provide you
with tools that:
 Define a PDE problem, e.g., define 2-D regions, boundary conditions, and PDE
coefficients.
 Numerically solve the PDE problem, e.g., generate unstructured meshes, discretize the
equations, and produce an approximation to the solution.
 Visualize the results.

25. Robust Control Toolbox


The Robust Control Toolbox™ product is a collection of functions and tools that help
you analyze and design multiinput-multioutput (MIMO) control systems with uncertain
elements. You can build uncertain LTI system models containing uncertain parameters
and uncertain dynamics. You get tools to analyze MIMO system stability margins and
worst case performance.

26. Signal Processing Toolbox


Signal Processing Toolbox™ software is a collection of tools based on the MATLAB ®
environment. The toolbox supports a wide range of signal processing operations, from
waveform generation to filter design and implementation, parametric modeling, and
spectral analysis. The toolbox provides two categories of tools, command-line
functions/objects and graphical user interfaces.

27. Spline Toolbox


Spline Toolbox software contains versions of the essential MATLAB ® programs of the
B-spline package (extended to handle also vector-valued splines) as described in A
Practical Guide to Splines, (Applied Math. Sciences Vol. 27, Springer Verlag, New York
(1978), xxiv + 392p; revised edition (2001), xviii+346p), hereafter referred to as PGS.
The toolbox makes it easy to create and work with piecewise-polynomial functions.

28. Statistics Toolbox


Statistics Toolbox™ software extends MATLAB® to support a wide range of common
statistical tasks. The toolbox contains two categories of tools:
 Building-block statistical functions for use in MATLAB programming
 Graphical user interfaces (GUIs) for interactive data analysis
Code for the building-block functions is open and extensible. Use the MATLAB Editor to
review, copy, and edit M-file code for any function. Extend the toolbox by copying code
to new M-files or by writing M-files that call toolbox functions.
Toolbox GUIs allow you to perform statistical visualization and analysis without writing
code. You interact with the GUIs using sliders, input fields, push buttons, etc. and the
GUIs automatically call building-block functions.
29. Symbolic Math Toolbox
Symbolic Math Toolbox™ software lets you to perform symbolic computations within
the MATLAB® numeric environment. It provides tools for solving and manipulating
symbolic math expressions and performing variable-precision arithmetic. The toolbox
contains hundreds of symbolic functions that leverage the MuPAD ® engine for a broad
range of mathematical tasks such as:
 Differentiation
 Integration
 Linear algebraic operations
 Simplification
 Transforms
 Variable-precision arithmetic
 Equation solving

30. System Identification Toolbox


System Identification Toolbox™ software lets you estimate linear and nonlinear
mathematical models of dynamic systems from measured data. Use the resulting models
for analyzing system dynamics, simulating the output of a system for a given input,
predicting future outputs based on previous observations of inputs and outputs, or for
control design.

31. Vehicle Network Toolbox


The Vehicle Network Toolbox™ provides the ability to communicate with in-vehicle
networks using Controller Area Network (CAN) protocol. It is a comprehensive toolbox
with a MATLAB® interface, Simulink® modeling support and a simple utility that
allows you to monitor CAN traffic.
You can learn more about the Vehicle Network Toolbox by following a simple workflow
and some easy examples. This chapter introduces the toolbox and provides some
guidelines and examples to use the Vehicle Network Toolbox to interface with the CAN
bus.

32. Wavelet Toolbox


Everywhere around us are signals that can be analyzed. For example, there are seismic
tremors, human speech, engine vibrations, medical images, financial data, music, and
many other types of signals. Wavelet analysis is a new and promising set of tools and
techniques for analyzing these signals.
Wavelet Toolbox™ software is a collection of functions built on the MATLAB®
technical computing environment. It provides tools for the analysis and synthesis of
signals and images, and tools for statistical applications, using wavelets and wavelet
packets within the framework of MATLAB.

MODULE 1 PROGRAMS:

INPUT:-
%operations on matrices
m1=[2 3 1;4 6 2;8 7 9]
m2=[5 3 2;4 3 7;8 1 5]
sum=m1+m2
product = m1*m2
inverse=m2^-1
e=eig(m1)
%plotting of graphs
theta=linspace(0,2*pi,10)
x=sin(theta)
y=cos(theta)
z=1:5
w=3*z-2
plot(x,y,z,w,'o')
axis('equal')
xlabel('sin(theta)')
ylabel('cos(theta)')

OUTPUT:-

m1 =
2 3 1
4 6 2
8 7 9

m2 =

5 3 2
4 3 7
8 1 5

sum =

7 6 3
8 9 9
16 8 14

product =

30 16 30
60 32 60
140 54 110

inverse =

0.0741 -0.1204 0.1389


0.3333 0.0833 -0.2500
-0.1852 0.1759 0.0278

e =

13.2170
-0.0000
3.7830

theta =

Columns 1 through 5

0 0.6981 1.3963 2.0944 2.7925

Columns 6 through 10
3.4907 4.1888 4.8869 5.5851 6.2832

x =

Columns 1 through 5

0 0.6428 0.9848 0.8660 0.3420

Columns 6 through 10

-0.3420 -0.8660 -0.9848 -0.6428 -0.0000

y =

Columns 1 through 5

1.0000 0.7660 0.1736 -0.5000 -0.9397

Columns 6 through 10

-0.9397 -0.5000 0.1736 0.7660 1.0000

z =

1 2 3 4 5

w =

1 4 7 10 13
INPUT:-
%Define a transfer fn and plot its pole-zero map
%file written by varun kumar kadian.
load numdemo Pd Cd
pzplot(Pd,'b',Cd,'r')
OUTPUT:-

MODULE 2
INTRODUCTION TO FUZZY LOGIC:

In recent years, the number and variety of applications of fuzzy logic have increased
significantly. The applications range from consumer products such as cameras, camcorders,
washing machines, and microwave ovens to industrial process control, medical instrumentation,
decision-support systems, and portfolio selection.

Fuzzy logic has two different meanings. In a narrow sense, fuzzy logic is a logical system, which
is an extension of multivalued logic. However, in a wider sense fuzzy logic (FL) is almost
synonymous with the theory of fuzzy sets, a theory which relates to classes of objects with
unsharp boundaries in which membership is a matter of degree. In this perspective, fuzzy logic in
its narrow sense is a branch of FL. Even in its more narrow definition, fuzzy logic differs both in
concept and substance from traditional multivalued logical systems.

In Fuzzy Logic Toolbox software, fuzzy logic should be interpreted as FL, that is, fuzzy logic in
its wide sense. What might be added is that the basic concept underlying FL is that of a linguistic
variable, that is, a variable whose values are words rather than numbers. In effect, much of FL
may be viewed as a methodology for computing with words rather than numbers. Although
words are inherently less precise than numbers, their use is closer to human intuition.
Furthermore, computing with words exploits the tolerance for imprecision and thereby lowers
the cost of solution.

A trend that is growing in visibility relates to the use of fuzzy logic in combination with
neurocomputing and genetic algorithms. More generally, fuzzy logic, neurocomputing, and
genetic algorithms may be viewed as the principal constituents of what might be called soft
computing. Unlike the traditional, hard computing, soft computing accommodates the
imprecision of the real world. The guiding principle of soft computing is: Exploit the tolerance
for imprecision, uncertainty, and partial truth to achieve tractability, robustness, and low solution
cost. In the future, soft computing could play an increasingly important role in the conception
and design of systems whose MIQ (Machine IQ) is much higher than that of systems designed by
conventional methods.

Fuzzy logic is all about the relative importance of precision: How important is it to be exactly
right when a rough answer will do?

BASIC THEORY OF FUZZY LOGIC:


Fuzzy Logic Toolbox™ software is a collection of functions built on the MATLAB® technical
computing environment. It provides tools to create and edit fuzzy inference systems within the
framework of MATLAB. We can also integrate our fuzzy systems into simulations with
Simulink® software. We can even build stand-alone C programs that call on fuzzy systems we
build with MATLAB. This toolbox relies heavily on graphical user interface (GUI) tools to help
us accomplish our work, although we can work entirely from the command line if we prefer.

The toolbox provides three categories of tools:

 Command line functions


 Graphical interactive tools
 Simulink blocks and examples

The first category of tools is made up of functions that we can call from the command line or
from our own applications. Many of these functions are MATLAB M-files, series of MATLAB
statements that implement specialized fuzzy logic algorithms. We can view the MATLAB code
for these functions using the statement

type function_name

We can change the way any toolbox function works by copying and renaming the M-file, then
modifying our copy. We can also extend the toolbox by adding our own M-files.

Secondly, the toolbox provides a number of interactive tools that let us access many of the
functions through a GUI. Together, the GUI-based tools provide an environment for fuzzy
inference system design, analysis, and implementation.

The third category of tools is a set of blocks for use with Simulink. These are specifically
designed for high speed fuzzy logic inference in the Simulink environment.

What makes the toolbox so powerful is the fact that most of human reasoning and concept
formation is linked to the use of fuzzy rules. By providing a systematic framework for computing
with fuzzy rules, the toolbox greatly amplifies the power of human reasoning. Further
amplification results from the use of MATLAB and graphical user interfaces, areas in which The
MathWorks™ has unparalleled expertise.

Another basic concept in FL, which plays a central role in most of its applications, is that of a
fuzzy if-then rule or, simply, fuzzy rule. Although rule-based systems have a long history of use
in Artificial Intelligence (AI), what is missing in such systems is a mechanism for dealing with
fuzzy consequents and fuzzy antecedents. In fuzzy logic, this mechanism is provided by the
calculus of fuzzy rules.
Why Use Fuzzy Logic?

Here is a list of general observations about fuzzy logic:

 Fuzzy logic is conceptually easy to understand.

The mathematical concepts behind fuzzy reasoning are very simple. Fuzzy logic is a
more intuitive approach without the far-reaching complexity.

 Fuzzy logic is flexible.

With any given system, it is easy to layer on more functionality without starting again
from scratch.

 Fuzzy logic is tolerant of imprecise data.

Everything is imprecise if you look closely enough, but more than that, most things are
imprecise even on careful inspection. Fuzzy reasoning builds this understanding into the
process rather than tacking it onto the end.

 Fuzzy logic can model nonlinear functions of arbitrary complexity.

You can create a fuzzy system to match any set of input-output data. This process is
made particularly easy by adaptive techniques like Adaptive Neuro-Fuzzy Inference
Systems (ANFIS), which are available in Fuzzy Logic Toolbox software.

 Fuzzy logic can be built on top of the experience of experts.

In direct contrast to neural networks, which take training data and generate opaque,
impenetrable models, fuzzy logic lets you rely on the experience of people who already
understand your system.

 Fuzzy logic can be blended with conventional control techniques.

Fuzzy systems don't necessarily replace conventional control methods. In many cases
fuzzy systems augment them and simplify their implementation.

 Fuzzy logic is based on natural language.

The basis for fuzzy logic is the basis for human communication. This observation
underpins many of the other statements about fuzzy logic. Because fuzzy logic is built on
the structures of qualitative description used in everyday language, fuzzy logic is easy to
use.

The last statement is perhaps the most important one and deserves more discussion. Natural
language, which is used by ordinary people on a daily basis, has been shaped by thousands of
years of human history to be convenient and efficient. Sentences written in ordinary language
represent a triumph of efficient communication.

When Not to Use Fuzzy Logic

Fuzzy logic is not a cure-all. When should you not use fuzzy logic? The safest statement is the
first one made in this introduction: fuzzy logic is a convenient way to map an input space to an
output space. If you find it's not convenient, try something else. If a simpler solution already
exists, use it. Fuzzy logic is the codification of common sense — use common sense when you
implement it and you will probably make the right decision. Many controllers, for example, do a
fine job without using fuzzy logic. However, if you take the time to become familiar with fuzzy
logic, you'll see it can be a very powerful tool for dealing quickly and efficiently with
imprecision and nonlinearity.

FUNCTIONS GENERALLY USED IN FUZZYLOGIC GUI:

GUI Tools and Plotting


anfisedit Open ANFIS Editor GUI

findcluster Interactive clustering GUI for fuzzy c-means and subclustering

fuzzy Open basic Fuzzy Inference System editor

mfedit Membership function editor

plotfis Plot Fuzzy Inference System

plotmf Plot all membership functions for given variable

ruleedit Rule editor and parser

ruleview Rule viewer and fuzzy inference diagram

surfview Open Output Surface Viewer

Membership Functions
dsigmf Built-in membership function composed of difference between two
sigmoidal membership functions

gauss2mf Gaussian combination membership function


gaussmf Gaussian curve built-in membership function

gbellmf Generalized bell-shaped built-in membership function

pimf Π-shaped built-in membership function

psigmf Built-in membership function composed of product of two sigmoidally


shaped membership functions

sigmf Sigmoidally shaped built-in membership function

smf S-shaped built-in membership function

trapmf Trapezoidal-shaped built-in membership function

trimf Triangular-shaped built-in membership function

zmf Z-shaped built-in membership function

FIS Data Structure


addmf Add membership function to Fuzzy Inference System

addrule Add rule to Fuzzy Inference System

addvar Add variable to Fuzzy Inference System

defuzz Defuzzify membership function

evalfis Perform fuzzy inference calculations

evalmf Generic membership function evaluation

gensurf Generate Fuzzy Inference System output surface

getfis Fuzzy system properties

mf2mf Translate parameters between membership functions

newfis Create new Fuzzy Inference System

parsrule Parse fuzzy rules


readfis Load Fuzzy Inference System from file

rmmf Remove membership function from Fuzzy Inference System

rmvar Remove variables from Fuzzy Inference System

setfis Set fuzzy system properties

showfis Display annotated Fuzzy Inference System

showrule Display Fuzzy Inference System rules

writefis Save Fuzzy Inference System to file

Advanced Fuzzy Inference Techniques


anfis Training routine for Sugeno-type Fuzzy Inference System (MEX only)

fcm Fuzzy c-means clustering

genfis1 Generate Fuzzy Inference System structure from data using grid
partition

genfis2 Generate Fuzzy Inference System structure from data using subtractive
clustering

genfis3 Generate Fuzzy Inference System structure from data using FCM
clustering

subclust Find cluster centers with subtractive clustering

Simulink Environment
fuzblock Simulink fuzzy logic library

sffis Fuzzy inference S-function for Simulink software


MODULE 2 PROBLEM:

%Program to find the run time of washing machine when dirtness


%of clothes and type of dirt are given.

INPUT:
a=newfis('washruntime');
a.input(1).name='dirtnessofclothes';
a.input(1).range=[0 100];
a.input(1).mf(1).name='small';
a.input(1).mf(1).type='trimf';
a.input(1).mf(1).params=[-50 0 50];
a.input(1).mf(2).name='medium';
a.input(1).mf(2).type='trimf';
a.input(1).mf(2).params=[0 50 100];
a.input(1).mf(3).name='large';
a.input(1).mf(3).type='trimf';
a.input(1).mf(3).params=[50 100 150];
a.input(2).name='typeofdirt';
a.input(2).range=[0 100];
a.input(2).mf(1).name='notgreasy';
a.input(2).mf(1).type='trimf';
a.input(2).mf(1).params=[-50 0 50];
a.input(2).mf(2).name='medium';
a.input(2).mf(2).type='trimf';
a.input(2).mf(2).params=[0 50 100];
a.input(2).mf(3).name='greasy';
a.input(2).mf(3).type='trimf';
a.input(2).mf(3).params=[50 100 150];
a.output(1).name='runtime';
a.output(1).range=[0 60];
a.output(1).mf(1).name='veryshort';
a.output(1).mf(1).type='trimf';
a.output(1).mf(1).params=[0 10 15];
a.output(1).mf(2).name='short';
a.output(1).mf(2).type='trimf';
a.output(1).mf(2).params=[10 15 23];
a.output(1).mf(3).name='medium';
a.output(1).mf(3).type='trimf';
a.output(1).mf(3).params=[15 23 40];
a.output(1).mf(4).name='long';
a.output(1).mf(4).type='trimf';
a.output(1).mf(4).params=[23 40 60];
a.output(1).mf(5).name='verylong';
a.output(1).mf(5).type='trimf';
a.output(1).mf(5).params=[40 60 75];
a.rule(1).antecedent=[3 3];
a.rule(1).consequent=[5];
a.rule(1).weight=1;
a.rule(1).connection=1;
a.rule(2).antecedent=[2 3];
a.rule(2).consequent=[4];
a.rule(2).weight=1;
a.rule(2).connection=1;
a.rule(3).antecedent=[1 3];
a.rule(3).consequent=[4];
a.rule(3).weight=1;
a.rule(3).connection=1;
a.rule(4).antecedent=[3 2];
a.rule(4).consequent=[4];
a.rule(4).weight=1;
a.rule(4).connection=1;
a.rule(5).antecedent=[2 2];
a.rule(5).consequent=[3];
a.rule(5).weight=1;
a.rule(5).connection=1;
a.rule(6).antecedent=[1 2];
a.rule(6).consequent=[3];
a.rule(6).weight=1;
a.rule(6).connection=1;
a.rule(7).antecedent=[3 1];
a.rule(7).consequent=[3];
a.rule(7).weight=1;
a.rule(7).connection=1;
a.rule(8).antecedent=[2 1];
a.rule(8).consequent=[2];
a.rule(8).weight=1;
a.rule(8).connection=1;
a.rule(9).antecedent=[1 1];
a.rule(9).consequent=[1];
a.rule(9).weight=1;
a.rule(9).connection=1
output=evalfis([20 25],a)

OUTPUT:
a =

name: 'washruntime'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'centroid'
impMethod: 'min'
aggMethod: 'max'
input: [1x2 struct]
output: [1x1 struct]
rule: [1x9 struct]

output =

19.3154

DETAILS OF FIS FILE:

[System]
Name='washruntime'
Type='mamdani'
Version=2.0
NumInputs=2
NumOutputs=1
NumRules=9
AndMethod='min'
OrMethod='max'
ImpMethod='min'
AggMethod='max'
DefuzzMethod='centroid'

[Input1]
Name='dirtnessofclothes'
Range=[0 100]
NumMFs=3
MF1='small':'trimf',[-50 0 50]
MF2='medium':'trimf',[0 50 100]
MF3='large':'trimf',[50 100 150]

[Input2]
Name='typeofdirt'
Range=[0 100]
NumMFs=3
MF1='notgreasy':'trimf',[-50 0 50]
MF2='medium':'trimf',[0 50 100]
MF3='greasy':'trimf',[50 100 150]

[Output1]
Name='runtime'
Range=[0 60]
NumMFs=5
MF1='veryshort':'trimf',[0 10 15]
MF2='short':'trimf',[10 15 23]
MF3='medium':'trimf',[15 23 40]
MF4='long':'trimf',[23 40 60]
MF5='verylong':'trimf',[40 60 75]

[Rules]
3 3, 5 (1) : 1
2 3, 4 (1) : 1
1 3, 4 (1) : 1
3 2, 4 (1) : 1
2 2, 3 (1) : 1
1 2, 3 (1) : 1
3 1, 3 (1) : 1
2 1, 2 (1) : 1
1 1, 1 (1) : 1

OUTPUT THROUGH GUI:


MODULE 3
PROBLEM:
%Program to control the speed of a motor by changing the input
%voltage using fuzzy logic in MATLAB. When a set point is
%defined, if for some reason, the motor runs faster, we need to
%slow it down by reducing the input voltage. If the motor slows
%below the set point, the input voltage must be increased so
%that the motor speed reaches the set point.

INPUT:

a=newfis('speed_control');
a.input(1).name='motorspeed';
a.input(1).range=[2280 2520 ];
a.input(1).mf(1).name='tooslow';
a.input(1).mf(1).type='trimf';
a.input(1).mf(1).params=[2280 2340 2400];
a.input(1).mf(2).name='jstrght';
a.input(1).mf(2).type='trimf';
a.input(1).mf(2).params=[2360 2400 2440];
a.input(1).mf(3).name='toofst';
a.input(1).mf(3).type='trimf';
a.input(1).mf(3).params=[2400 2460 2520];
a.output(1).name='voltage';
a.output(1).range=[2.32 2.48];
a.output(1).mf(1).name='slowdown'
a.output(1).mf(1).type='trimf';
a.output(1).mf(1).params=[2.32 2.36 2.40];
a.output(1).mf(2).name='nochange';
a.output(1).mf(2).type='trimf';
a.output(1).mf(2).params=[2.38 2.40 2.42];
a.output(1).mf(3).name='speedup';
a.output(1).mf(3).type='trimf';
a.output(1).mf(3).params=[2.40 2.44 2.48];
a.rule(1).antecedent=[1 ];
a.rule(1).consequent=[3];
a.rule(1).weight=1;
a.rule(1).connection=1;
a.rule(2).antecedent=[2];
a.rule(2).consequent=[2];
a.rule(2).weight=1;
a.rule(2).connection=1;
a.rule(3).antecedent=[3];
a.rule(3).consequent=[1];
a.rule(3).weight=1;
a.rule(3).connection=1
output=evalfis([2500],a)
OUTPUT:

a =

name: 'speed_control'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'centroid'
impMethod: 'min'
aggMethod: 'max'
input: [1x1 struct]
output: [1x1 struct]
rule: [1x3 struct]

output =

2.3600

DETAILS OF FIS FILE:

[System]
Name='speed_control'
Type='mamdani'
Version=2.0
NumInputs=1
NumOutputs=1
NumRules=3
AndMethod='min'
OrMethod='max'
ImpMethod='min'
AggMethod='max'
DefuzzMethod='centroid'

[Input1]
Name='motorspeed'
Range=[2280 2520]
NumMFs=3
MF1='tooslow':'trimf',[2280 2340 2400]
MF2='jstrght':'trimf',[2360 2400 2440]
MF3='toofst':'trimf',[2400 2460 2520]

[Output1]
Name='voltage'
Range=[2.32 2.48]
NumMFs=3
MF1='slowdown':'trimf',[2.32 2.36 2.4]
MF2='nochange':'trimf',[2.38 2.4 2.42]
MF3='speedup':'trimf',[2.4 2.44 2.48]

[Rules]
1, 3 (1) : 1
2, 2 (1) : 1
3, 1 (1) : 1

OUTPUT THROUGH GUI:


SUMMARY
Computation work is done effectively and accurately by
implemeting fuzzlogic in no time.It is seen that working in
fuzzylogy to solve day to day small problems like finding
runtime of washing machine, regulating speed of
motor,deciding the amount of tip and many others is easy and
works effectively. We can use it almost evrywhere. It can also
be combined with other toolboxes of matlab for solving
complicated problems for ex. modeling inverse kinematics in
robotic arm,modelingtraffic pattern using subtractive
clustering,gas mileage prediction,chaotic time series
prediction,temperature control in shower etc..We can also use
fuzzylogic software with other technical computing software for
solving problems with fuzzylogic.
REFERENCES:

1.http://www.mathworks.com/
2.A few matlab books written by Rudra
Pratap,Otto and Denier.
3.Matlab toolbox for fuzzylogic and matlab
help.
4.www.google.co.in

You might also like