# Fuzzy system in MATLAB

## Description

The theory of fuzzy sets was proposed in 1965 by Professor Lotfi Asgarzadeh, an Iranian scientist and professor at Berkeley University in the United States. The word fuzzy in the Oxford Dictionary is defined vaguely, vaguely, and inaccurately. Using this model is suitable for when the data is vague, uncertain, and inaccurate.

Fuzzy theory includes four steps of fuzzy construction, fuzzy law database, fuzzy inference engine, and non-fuzzy construction.

### Comparison of fuzzy and logical logic by Professor Lotfi zadeh:

Classic logic is like a person in a black formal dress, white blouse, black tie, shiny shoes, etc. coming to a formal party, and fuzzy logic is somewhat similar to a person in a formal dress, pants, T-shirt, and shoes. Cloth has come to the same party. This dress was not accepted in the past, but today it is different.

### Definition of fuzzy systems and their types

The word fuzzy is vaguely defined in the Oxford Dictionary. If we want to define the theory of fuzzy sets, we must say that it is a theory to act in conditions of uncertainty; This theory is able to mathematically formulate many concepts, variables, and systems that are inaccurate and provide the basis for reasoning, inference, control, and decision-making in conditions of uncertainty.

### Why fuzzy systems?

Our real-world is too complex to come up with an accurate description; Therefore, for a model, an approximate or fuzzy description must be introduced that is acceptable and analyzable.
As we move towards the information age, human knowledge becomes very important. We, therefore, need a hypothesis that can systematically formulate human knowledge and incorporate it, along with other mathematical models, into engineering systems.

### What are fuzzy systems like?

Fuzzy systems are systems based on knowledge or rules; The heart of a fuzzy system is a knowledge base made up of fuzzy if-then rules.
An if-then fuzzy rule is an if-then expression whose words are defined by continuous belonging functions.

Example:
If the car speed is high, then apply less force to the accelerator pedal.
The words “high” and “low” are denoted by belonging functions;

Example:
Suppose we want to design controllers that control the speed of the car automatically. The solution is to simulate drivers’ behavior; This means turning the rules that the driver uses while driving into an automatic controller.

In colloquial speech, drivers naturally use the following three rules while driving:
If the speed is low, then apply more force to the accelerator pedal.
If the speed is medium, then apply a balanced force to the accelerator pedal.
If the speed is high, then apply less force to the accelerator pedal.

In short, the starting point for building a fuzzy system is to obtain a set of if-then-fuzzy rules from the knowledge of experts or the field; The next step is to combine these rules into a single system.

### Types of fuzzy systems

Mamdani fuzzy systems
Takagi-Sugnokang Fuzzy Systems (TSK)
Neurophasic systems

### Mamdani fuzzy system

The fuzzy inference engine combines these rules into a mapping from fuzzy sets in the input space to fuzzy sets in the output space based on the principles of fuzzy logic.
The main problem with Mamdani fuzzy systems is that their inputs and outputs are fuzzy sets. In engineering systems, inputs and outputs are variables with real values.
To solve this problem, Takagi Sugeno has introduced another type of fuzzy system whose inputs and outputs are variables with real values.

### Takagi-Sugo fuzzy system

Thus the fuzzy rule has become a simple relation from a descriptive expression to linguistic values; For example, in the case of a car, it can be stated that if the speed of the car is X, then the force on the accelerator pedal is equal to Y = CX.
The main problems of TSK fuzzy system are:
The “then” section is the rule of a mathematical formula and therefore does not provide a framework for the representation of human knowledge.
This system does not leave us free to apply the various principles of fuzzy logic, and as a result, there is no flexibility of fuzzy systems in this structure.
To solve these problems, the third type of fuzzy system was used, namely a fuzzy system with fuzzy generators and non-fuzzy generators.

### Educational video headlines : (zero to one hundred)

Introduction

History of fuzzy systems

Where did the fuzzy logical idea start?

What is human reasoning?

The concept of degree and truth table

What does fuzzy logic do?

The concept of rules in fuzzy

Explanation of fuzzy system block diagram

The difference between crisp value and fuzzy value

Description fuzzy inference system (FIS)

A complete description of an example of a fuzzy system

Concept of fuzzy set

Membership degree

Example of a fuzzy set

The difference between classical set and fuzzy set

Reasoning in fuzzy logic

Boolean binary logic

The concept of membership function

Two-tier membership function

Online membership function

Input Interpretation that has several membership functions

Types of MATLAB membership functions

Triangular and trapezoidal membership function and Gaussian and Sigmoid

Input parameters of membership functions

Fuzzy operations

AND and OR and NOT fuzzy

Fuzzy truth table

Multiple logic

How are fuzzy rules determined?

The concept of antecedent and consequent

defuzzifier

implication

An example block diagram of a fuzzy system

Applications of fuzzy logic

Description of the fuzzy inference system

Fuzzy input

Fuzzy operations

Implication operation

Aggregation operation

Defuzzification operation

MATLAB programming of fuzzy systems type 1

A simple example

Steps of designing a fuzzy system

Input change interval

Fuzzy system design through GUI

Types of fuzzy systems

Mamdani and Takagi Sugno

FuzzyLogicDesigner command

Set up incoming membership functions in MATLAB

Explain the membership functions definition window

Manually set up membership functions

The parametric setting of membership functions

Assign names to inputs and outputs

Adjust the range of range changes

Naming membership functions

Definition of rules

Delete rule

Change rule

Concept of connection in rule

The concept of not in the rule

The concept of weight in rule

Surface observation in the fuzzy system

Set X input and Y input

Graphical view of a rule in MATLAB

Save a fuzzy system

The fis extension in MATLAB

Open a stored fuzzy system

A variety of other membership functions in the fuzzy system

Trimf, trapmf, gbelmf, gaussmf, gauss2mf, sigmf, dsigmf, psigmf, pimf, smf, zmf

Three-dimensional surface view

Manually change fis file

Add a membership function to the input in the fis file

Explain a fis file line by line

Set the rule as numbers

Build a fuzzy system in MATLAB through coding

Newfis command

Manual definition of rules

Apply input to the fuzzy system