IF..THEN rules

3 次查看(过去 30 天)
muhammad muda
muhammad muda 2019-8-26
Hi,
I want to create if..then rules using Matlab coding. I know that there is tool box for fuzzy, but I am trying to do it in a different way.
Suppose I have 3 membership functions (x1 and x2 are the inputs, and y is the output).
x = 0:0.01:1
x1 = gaussmf(x, [0.125 0.5]) %medium
x2 = gaussmf(x, [0.0625 0.125]) %low
y = gaussmf(x, [0.15 0.6]) %medium
Now I try to relate these membership functions based on this rule:
'If x1 is medium and x2 is low, then y is medium.'
Is there any code for this?
Thank you.
  6 个评论
Adam Danz
Adam Danz 2019-8-26
If the red curve is the definition of "low" and the blue curves are definitions of "medium" then I would calculate where those curve intersect. If there are 2 "medium" curves, you could take the average of the 2 x values at the two intersections.
muhammad muda
muhammad muda 2019-8-26
sorry for the misunderstanding. the terms low and medium are just for examples, hence are not the focus of the question. what i am trying to do is to build a fuzzy inference system; adding variables (input and output), add membership functions for each variables, and finally adding the rules. I know, this is similar to the fuzzy toolbox, but I am just trying different method (coding). any simpilified examples are welcome. by the way thank you all for the help.

请先登录,再进行评论。

采纳的回答

Prabhan Purwar
Prabhan Purwar 2019-9-3
Hey,
Following is an example going through various process included for achieving a fully functional fuzzy inference system
Take the example of an autonomous plane flying at an optimal altitude (Ao), and we are trying to control throttle based on altitude.
Ar is the current altitude and error= Ar — Ao. Error-dot is equal to the rate of change of error.
Based on error Let us define the outputs as Increase throttle, No Change, and Decrease Throttle.
Step 1: Initialization
Crisp Input
If the change in error is decreasing = Negative
If the change in error is not change = Zero
If the change in error is increasing = Positive
Crisp output
Increase throttle
(No change)
Decrease throttle.
Step 2: Fuzzification
Assigning a member function for crisp values. Membership function can be Sigmoid function (sigmf), Triangular function (trimf) and many more. Three main membership functions are Increase throttle, (No change) and Decrease throttle.
Step 3:
IF-THEN rules:
If error is Negative (Ar < Ao) and error-dot is Negative THEN Increase throttle.
If error is Zero (Ar = Ao) and error-dot is Zero THEN No Change.
If error is Negative (Ar < Ao) and error-dot is Zero THEN Increase throttle.
In matrix format
The graphs for the membership function sets (error, error-dot and output) looks like:
For the output
For altitude error:
Green color is assigned where answer > 0.
Step 4:
Inference Mechanism
Fuzzy inferences mechanisms are
1. Mamdani fuzzy inference
2. Sugeno fuzzy inference
3. Tsukamoto fuzzy inference
Step 5:
Defuzzification
Using Root-sum-squared calculate the strength of each output membership function, Decrease Throttle, No Change and Increase Throttle.
For more details look over following link:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Fuzzy Inference System Modeling 的更多信息

产品


版本

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by