MATLAB Answers

IF..THEN rules

14 ビュー (過去 30 日間)
muhammad muda
muhammad muda 2019 年 8 月 26 日
回答済み: Prabhan Purwar 2019 年 9 月 3 日
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 件のコメント

表示 3 件の古いコメント
darova 2019 年 8 月 26 日
Where is the edge between low and medium?
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 日
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:
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 件のコメント


その他の回答 (0 件)




Community Treasure Hunt

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

Start Hunting!

Translated by