📄 mohu.txt
字号:
>> clear
>> b=readfis('myfuzzy2')
b =
name: 'myfuzzy2'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'centroid'
impMethod: 'min'
aggMethod: 'max'
rule: []
>> b=addvar(b,'input','error',[-4 4])
b =
name: 'myfuzzy2'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'centroid'
impMethod: 'min'
aggMethod: 'max'
rule: []
input: [1x1 struct]
>> b=addvar(b,'output','control',[-4 4])
b =
name: 'myfuzzy2'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'centroid'
impMethod: 'min'
aggMethod: 'max'
rule: []
input: [1x1 struct]
output: [1x1 struct]
>> addmf
??? Input argument 'fis' is undefined.
Error in ==> C:\MATLAB6p5\toolbox\fuzzy\fuzzy\addmf.m
On line 35 ==> numInputs=length(fis.input);
>> b=addmf(b,'input',1,'NL','trimf',[-4 -4 -2])
b =
name: 'myfuzzy2'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'centroid'
impMethod: 'min'
aggMethod: 'max'
rule: []
input: [1x1 struct]
output: [1x1 struct]
>> showfis(b)
1. Name myfuzzy2
2. Type mamdani
3. Inputs/Outputs [1 1]
4. NumInputMFs 1
5. NumOutputMFs 0
6. NumRules 0
7. AndMethod min
8. OrMethod max
9. ImpMethod min
10. AggMethod max
11. DefuzzMethod centroid
12. InLabels error
13. OutLabels control
14. InRange [-4 4]
15. OutRange [-4 4]
16. InMFLabels NL
17. InMFTypes trimf
18. InMFParams [-4 -4 -2 0]
>> b=addmf(b,'input',1,'NS','trimf',[-4 -2 0])
b =
name: 'myfuzzy2'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'centroid'
impMethod: 'min'
aggMethod: 'max'
rule: []
input: [1x1 struct]
output: [1x1 struct]
>> showfis(b)
1. Name myfuzzy2
2. Type mamdani
3. Inputs/Outputs [1 1]
4. NumInputMFs 2
5. NumOutputMFs 0
6. NumRules 0
7. AndMethod min
8. OrMethod max
9. ImpMethod min
10. AggMethod max
11. DefuzzMethod centroid
12. InLabels error
13. OutLabels control
14. InRange [-4 4]
15. OutRange [-4 4]
16. InMFLabels NL
17. NS
18. InMFTypes trimf
19. trimf
20. InMFParams [-4 -4 -2 0]
21. [-4 -2 0 0]
>> b=addmf(b,'input',1,'Z','trimf',[-2 0 2])
b =
name: 'myfuzzy2'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'centroid'
impMethod: 'min'
aggMethod: 'max'
rule: []
input: [1x1 struct]
output: [1x1 struct]
>> b=addmf(b,'input',1,'PS','trimf',[0 2 4])
b =
name: 'myfuzzy2'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'centroid'
impMethod: 'min'
aggMethod: 'max'
rule: []
input: [1x1 struct]
output: [1x1 struct]
>> b=addmf(b,'input',1,'PL','trimf',[2 4 4])
b =
name: 'myfuzzy2'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'centroid'
impMethod: 'min'
aggMethod: 'max'
rule: []
input: [1x1 struct]
output: [1x1 struct]
>> showfis(b)
1. Name myfuzzy2
2. Type mamdani
3. Inputs/Outputs [1 1]
4. NumInputMFs 5
5. NumOutputMFs 0
6. NumRules 0
7. AndMethod min
8. OrMethod max
9. ImpMethod min
10. AggMethod max
11. DefuzzMethod centroid
12. InLabels error
13. OutLabels control
14. InRange [-4 4]
15. OutRange [-4 4]
16. InMFLabels NL
17. NS
18. Z
19. PS
20. PL
21. InMFTypes trimf
22. trimf
23. trimf
24. trimf
25. trimf
26. InMFParams [-4 -4 -2 0]
27. [-4 -2 0 0]
28. [-2 0 2 0]
29. [0 2 4 0]
30. [2 4 4 0]
>> b=addmf(b,'output',1,'NL','trimf',[-4 -4 -2])
b =
name: 'myfuzzy2'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'centroid'
impMethod: 'min'
aggMethod: 'max'
rule: []
input: [1x1 struct]
output: [1x1 struct]
>> b=addmf(b,'output',1,'NS','trimf',[-4 -2 0])
b =
name: 'myfuzzy2'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'centroid'
impMethod: 'min'
aggMethod: 'max'
rule: []
input: [1x1 struct]
output: [1x1 struct]
>> b=addmf(b,'output',1,'Z','trimf',[-2 0 2])
b =
name: 'myfuzzy2'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'centroid'
impMethod: 'min'
aggMethod: 'max'
rule: []
input: [1x1 struct]
output: [1x1 struct]
>> b=addmf(b,'output',1,'PS','trimf',[0 2 4])
b =
name: 'myfuzzy2'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'centroid'
impMethod: 'min'
aggMethod: 'max'
rule: []
input: [1x1 struct]
output: [1x1 struct]
>> b=addmf(b,'output',1,'PL','trimf',[2 4 4])
b =
name: 'myfuzzy2'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'centroid'
impMethod: 'min'
aggMethod: 'max'
rule: []
input: [1x1 struct]
output: [1x1 struct]
>> shoufis(b)
??? Undefined function or variable 'shoufis'.
>> showfis(b)
1. Name myfuzzy2
2. Type mamdani
3. Inputs/Outputs [1 1]
4. NumInputMFs 5
5. NumOutputMFs 5
6. NumRules 0
7. AndMethod min
8. OrMethod max
9. ImpMethod min
10. AggMethod max
11. DefuzzMethod centroid
12. InLabels error
13. OutLabels control
14. InRange [-4 4]
15. OutRange [-4 4]
16. InMFLabels NL
17. NS
18. Z
19. PS
20. PL
21. OutMFLabels NL
22. NS
23. Z
24. PS
25. PL
26. InMFTypes trimf
27. trimf
28. trimf
29. trimf
30. trimf
31. OutMFTypes trimf
32. trimf
33. trimf
34. trimf
35. trimf
36. InMFParams [-4 -4 -2 0]
37. [-4 -2 0 0]
38. [-2 0 2 0]
39. [0 2 4 0]
40. [2 4 4 0]
41. OutMFParams [-4 -4 -2 0]
42. [-4 -2 0 0]
43. [-2 0 2 0]
44. [0 2 4 0]
45. [2 4 4 0]
>> rulelist=[1 1 1;2 2 1;3 3 1;4 4 1;5 5 1;]
rulelist =
1 1 1
2 2 1
3 3 1
4 4 1
5 5 1
>> rulelist(:,4)=1
rulelist =
1 1 1 1
2 2 1 1
3 3 1 1
4 4 1 1
5 5 1 1
>> b=addrule(b,rulelist)
b =
name: 'myfuzzy2'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'centroid'
impMethod: 'min'
aggMethod: 'max'
rule: [1x5 struct]
input: [1x1 struct]
output: [1x1 struct]
>> writefis(b,'myfuzzy2')
ans =
myfuzzy2
>> help evalfis
EVALFIS Perform fuzzy inference calculations.
Y = EVALFIS(U,FIS) simulates the Fuzzy Inference System FIS for the
input data U and returns the output data Y. For a system with N
input variables and L output variables,
* U is a M-by-N matrix, each row being a particular input vector
* Y is M-by-L matrix, each row being a particular output vector.
Y = EVALFIS(U,FIS,NPts) further specifies number of sample points
on which to evaluate the membership functions over the input or output
range. If this argument is not used, the default value is 101 points.
[Y,IRR,ORR,ARR] = EVALFIS(U,FIS) also returns the following range
variables when U is a row vector (only one set of inputs is applied):
* IRR: the result of evaluating the input values through the membership
functions. This is a matrix of size Nr-by-N, where Nr is the number
of rules, and N is the number of input variables.
* ORR: the result of evaluating the output values through the membership
functions. This is a matrix of size NPts-by-Nr*L. The first Nr
columns of this matrix correspond to the first output, the next Nr
columns correspond to the second output, and so forth.
* ARR: the NPts-by-L matrix of the aggregate values sampled at NPts
along the output range for each output.
Example:
fis = readfis('tipper');
out = evalfis([2 1; 4 9],fis)
This generates the response
out =
7.0169
19.6810
See also READFIS, RULEVIEW, GENSURF.
>> out=evalfis(-4,b)
out =
-3.3600
>> x=-4:4
x =
-4 -3 -2 -1 0 1 2 3 4
>> out=evalfis(x',b)
out =
-3.3600
-2.2586
-2.0000
-1.0000
0.0000
1.0000
2.0000
2.2586
3.3600
>> round(out)
ans =
-3
-2
-2
-1
0
1
2
2
3
>> b=setfis(b,'defuzzymethod','mom')
??? Error using ==> setfis
There is no FIS system property called defuzzymethod
>> b=setfis(b,'defuzzmethod','mom')
b =
name: 'myfuzzy2'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'mom'
impMethod: 'min'
aggMethod: 'max'
rule: [1x5 struct]
input: [1x1 struct]
output: [1x1 struct]
>> out=evalfis(x',b)
out =
-4.0000
-2.5200
-2.0000
-1.0000
0
1.0000
2.0000
2.5200
4.0000
>> round(out)
ans =
-4
-3
-2
-1
0
1
2
3
4
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -