having error while running fuzzy controller and fuzzy set of matlab 2017 in matlab 2023?

2 inputs and 1 output with mamdani rule.

6 Comments

Show what you did. Make it easy to get help, instead of people needing to make wild guesses as to what seems to be the problem.
@shilpam malik, Can you attach the zipped file of the .fis? Click this icon .
You can also open the .fis file with Notepad++. Copy and paste the content here like this:
[System]
Name='Fuzzy_Staircase'
Type='mamdani'
Version=2.0
NumInputs=1
NumOutputs=1
NumRules=3
AndMethod='min'
OrMethod='max'
ImpMethod='min'
AggMethod='max'
DefuzzMethod='centroid'
[Input1]
Name='input1'
Range=[-1 1]
NumMFs=3
MF1='mf1':'trimf',[-1.8 -1 -0.2]
MF2='mf2':'trimf',[-0.6 0 0.6]
MF3='mf3':'trimf',[0.2 1 1.8]
[Output1]
Name='output1'
Range=[-2 2]
NumMFs=3
MF1='mf1':'trimf',[-1.8 -1 -0.2]
MF2='mf2':'trimf',[-0.8 0 0.8]
MF3='mf3':'trimf',[0.2 1 1.8]
[Rules]
1, 1 (1) : 1
2, 2 (1) : 1
3, 3 (1) : 1
Name='abc'
Type='mamdani'
Version=2.0
NumInputs=2
NumOutputs=1
NumRules=25
AndMethod='min'
OrMethod='max'
ImpMethod='min'
AggMethod='max'
DefuzzMethod='centroid'
[Input1]
Name='error'
Range=[-1 1]
NumMFs=5
MF1='NB':'trapmf',[-1.72 -1.08 -0.8 -0.7]
MF2='NS':'trimf',[-0.8 -0.7 0]
MF3='Z':'trimf',[-0.7 0 0.7]
MF4='PS':'trimf',[0 0.7 0.8]
MF5='PB':'trapmf',[0.7 0.8 1.7 1.8]
[Input2]
Name='Derror'
Range=[-1 1]
NumMFs=5
MF1='NB':'trapmf',[-1.7 -1.5 -0.8 -0.7]
MF2='Z':'trimf',[-0.7 0 0.7]
MF3='NS':'trimf',[-0.8 -0.7 0]
MF4='PS':'trimf',[0 0.7 0.8]
MF5='PB':'trapmf',[0.7 0.8 1.3 1.5]
[Output1]
Name='U'
Range=[-1 1]
NumMFs=5
MF1='NB':'trapmf',[-1.5 -1.4 -0.8 -0.7]
MF2='Z':'trimf',[-0.7 0 0.7]
MF3='PB':'trapmf',[0.7 0.8 1.28 1.52]
MF4='NS':'trimf',[-0.8 -0.7 0]
MF5='PS':'trimf',[0 0.7 0.8]
[Rules]
1 1, 1 (1) : 1
1 3, 1 (1) : 1
1 2, 1 (1) : 1
1 4, 4 (1) : 1
1 5, 2 (1) : 1
2 1, 1 (1) : 1
2 3, 1 (1) : 1
2 2, 1 (1) : 1
2 4, 2 (1) : 1
2 5, 5 (1) : 1
3 1, 1 (1) : 1
3 3, 4 (1) : 1
3 2, 2 (1) : 1
3 4, 5 (1) : 1
3 5, 3 (1) : 1
4 1, 4 (1) : 1
4 3, 2 (1) : 1
4 2, 5 (1) : 1
4 4, 3 (1) : 1
4 5, 3 (1) : 1
5 1, 2 (1) : 1
5 3, 5 (1) : 1
5 2, 3 (1) : 1
5 4, 3 (1) : 1
5 5, 3 (1) : 1

Your FIS generates a saturation surface. What specific error did you get in MATLAB R2023?

---Input 2 expects a value in range [-1 1] but has a value of -1.77138. no rules fired for Output 1. Defuzzified output value set to its mean range value 0.
Every time i change the range of second input it exceeds the output giving output U as 0.

Sign in to comment.

Answers (1)

All five membership functions of Input 2 are defined in the range [-1, 1]. However, when Input 2 has a value of -1.77138 that is outside the range, none of the rules are triggered. Consequently, it returns the mid value of the Output range, that is (-1 + 1)/2 = 0, by default in Fuzzy Logic Toolbox.

To address the issue, make sure that the MFs are designed to cover the entire operating range of Input 2. For example, if the operating range is [-2, 2], the MFs should look like the following:

11 Comments

The same .fis file with same range and MFS is running absolutely fine in MATLAB 2018 but not in 2023.

Do you mean, in MATLAB R2018, the FIS returns some non-zero value when the value of Input 2 is outside of the range [-1, 1]?

The FIS is expected to return zero (mean output value) because no rules fired. If it returns a non-zero value in R2018 when the input value of 1.77138 clearly lies outside of the input range [-1, 1], then you need to investigate further.

When the Derivative of Error is 1.77138, what is the input value of Error?

I have written the entire code to generate the fuzzy system based on the your info in this comment, in order to demonstrate why it produces the "No rules fired for Output 1" error when the value of Input 2 is outside the range of [-1, 1].
Could you please provide the actual value of Input 1 when you ran the .fis file in R2017 and R2018?
%% Mamdani Fuzzy System
fis = mamfis;
% Fuzzy Input 1
ud1 = 1; % universe of discourse for input 1
fis = addInput(fis, [-ud1 +ud1], 'Name', 'x');
fis = addMF(fis, 'x', 'trapmf', ud1*[-1.72 -1.08 -0.8 -0.7], 'Name', 'NB');
fis = addMF(fis, 'x', 'trimf', ud1*[-0.8 -0.7 0.0], 'Name', 'NS');
fis = addMF(fis, 'x', 'trimf', ud1*[-0.7 0.0 0.7], 'Name', 'ZR');
fis = addMF(fis, 'x', 'trimf', ud1*[ 0.0 0.7 0.8], 'Name', 'PS');
fis = addMF(fis, 'x', 'trapmf', ud1*[ 0.7 0.8 1.7 1.8], 'Name', 'PB');
% Fuzzy Input 2
ud2 = 1; % universe of discourse for input 2
fis = addInput(fis, [-ud2 +ud2], 'Name', 'y');
fis = addMF(fis, 'y', 'trapmf', ud2*[-1.7 -1.5 -0.8 -0.7], 'Name', 'NB');
fis = addMF(fis, 'y', 'trimf', ud2*[-0.7 0.0 0.7], 'Name', 'ZR');
fis = addMF(fis, 'y', 'trimf', ud2*[-0.8 -0.7 0.0], 'Name', 'NS');
fis = addMF(fis, 'y', 'trimf', ud2*[ 0.0 0.7 0.8], 'Name', 'PS');
fis = addMF(fis, 'y', 'trapmf', ud2*[ 0.7 0.8 1.3 1.5], 'Name', 'PB');
% Fuzzy Output
udo = 1; % universe of discourse for output
fis = addOutput(fis, [-udo +udo], 'Name', 'u');
fis = addMF(fis, 'u', 'trapmf', udo*[-1.5 -1.4 -0.8 -0.7], 'Name', 'NB');
fis = addMF(fis, 'u', 'trimf', udo*[-0.7 0.0 0.7], 'Name', 'ZR');
fis = addMF(fis, 'u', 'trapmf', udo*[ 0.7 0.8 1.28 1.52], 'Name', 'PB');
fis = addMF(fis, 'u', 'trimf', udo*[-0.8 -0.7 0.0], 'Name', 'NS');
fis = addMF(fis, 'u', 'trimf', udo*[ 0.0 0.7 0.8 ], 'Name', 'PS');
% Fuzzy Rules
rules = [
1 1, 1 1 1
1 3, 1 1 1
1 2, 1 1 1
1 4, 4 1 1
1 5, 2 1 1
2 1, 1 1 1
2 3, 1 1 1
2 2, 1 1 1
2 4, 2 1 1
2 5, 5 1 1
3 1, 1 1 1
3 3, 4 1 1
3 2, 2 1 1
3 4, 5 1 1
3 5, 3 1 1
4 1, 4 1 1
4 3, 2 1 1
4 2, 5 1 1
4 4, 3 1 1
4 5, 3 1 1
5 1, 2 1 1
5 3, 5 1 1
5 2, 3 1 1
5 4, 3 1 1
5 5, 3 1 1
];
fis = addRule(fis, rules);
%% Plots
figure(1)
subplot(211)
plotmf(fis, 'input', 1, 2001), grid on,
xlabel('Input x (Error)')
title('Membership Functions')
subplot(212)
plotmf(fis, 'input', 2, 2001), grid on,
xlabel('Input y (Derivative of Error)')
title('Membership Functions')
figure(2)
plotmf(fis, 'output', 1, 2001), grid on,
xlabel('Output, u')
title('Membership Functions')
figure(3)
opt = gensurfOptions('NumGridPoints', 51);
gensurf(fis, opt);
title('Control Surface')
%% Evaluation
input_x_value = 0.5;
input_y_value = -1.77138;
out = evalfis(fis, [input_x_value, input_y_value])
Warning: Input 2 expects a value in range [-1 1], but has a value of -1.77138.
Warning: No rules fired for Output 1. Defuzzified output value set to its mean range value 0.
out = 0
i am getting this error only
please suggest me the error in these rules
I am trying to help you, but I do not have sufficient info to investigate this problem further. Perhaps I can guide you if you provide me with the necessary details to identify the issue.
You must have used this .fis file in a specific application Otherwise, it would not generate this error. Could you please clarify where you have used this .fis file?
I am using this .fis file in a controller for running simulink.
Good, @shilpam malik! We now understand that when you run the Simulink model, certain values from the state variables, specifically the error (e) and the derivative of error (de), are fed into the fuzzy inference system (.fis) to generate the actuated output (u).
At some point, the fuzzy control system operates outside the defined range of [-1, 1] for 'de', which triggers the "No rules fired for Output 1" error, as there are no rules (specifically, the membership functions) defined for values outside this range.
In your designed .fis, could you try re-scaling the operating range for de so that it becomes [-2, 2]? Your initial Mamdani design appears acceptable. So, the issue seems to lie solely with the operating range.
Please let me know if this approach works.
Whenever i tried changing the range again same error comes.
eg. if i change [-2,2] operating range is beyond [-2,2] value comes out 2.78.
if i chnge the the operating range to [-5,5] again the value goes out of range.
Good, @shilpam malik! This represents another step forward. We can explore other approaches. If you have the mathematical model of the system in Simulink, whether in State-space or Transfer Function form, please provide it here. I can reconstruct it to investigate the fuzzy control issue.
The following examples will give you an idea of how the mathematical model appears:
State-space model (generally described using 4 matrices, A, B, C, D):
sys = rss(2)
sys = A = x1 x2 x1 -3.249 1.165 x2 0.7234 -2.291 B = u1 x1 -1.079 x2 0.4604 C = x1 x2 y1 -0.2372 1.081 D = u1 y1 0 Continuous-time state-space model.
Transfer function model (generally described as a rational function, which is a ratio of two polynomials):
Gp = tf(sys)
Gp = 0.7536 s + 1.232 -------------------- s^2 + 5.54 s + 6.601 Continuous-time transfer function.

Sign in to comment.

Categories

Find more on Fuzzy Logic Toolbox in Help Center and File Exchange

Products

Release

R2023a

Asked:

on 24 Jul 2025

Commented:

on 28 Jul 2025

Community Treasure Hunt

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

Start Hunting!