What should I do if I get "Error: Invalid FIS. PARAMS field of constant output MF must contain a scalar"

2 views (last 30 days)
I'm a newbie to this forum. I'm facing the following problem in using the fuzzy logic function evalfis.
Below is the code snippet:
a = addvar(Sen_Val,'output','Confidence',[0 20]);
a = addmf(Sen_Val,'output',1,'Very_Low','constant',[0 0.3]);
a = addmf(Sen_Val,'output',1,'Low','constant',[0.30001 0.7]);
a = addmf(Sen_Val,'output',1,'Very_High','constant',[0.70001 1]);
output=evalfis(Fuzz_in,a,5)
% Here Fuzz_in is a 5X3 matrix
Below is the error message displayed:
??? Error using ==> evalfismex
Invalid FIS. PARAMS field of constant output MF must contain a scalar.
Error in ==> test at 163
output=evalfismex(Fuzz_in,a,5)
Requesting for your help to overcome this error. Thanks in advance Nithya

Answers (1)

Sam Chak
Sam Chak on 1 May 2025
The conclusion part of the Sugeno If–Then inference does not have the typical output membership functions (MFs) {triMF, trapMF, gaussMF} defined as the Mamdani fuzzy system does. If x is the input vector and y is the output vector, the output of each rule is defined as a function of the inputs, .
However, the MATLAB Fuzzy Logic Toolbox, unfortunately, still only allows for 'straight line' functions. These can be either linear combinations of the inputs, , or a constant function, . A constant function can be thought of as a scalar-valued function (outputting the same single number for every input value). Thus, the parameter field of the so-called 'constant output MF' must be a scalar, as shown in the following syntax:
fis = addMF(fis, 'outvar', 'constant', 7, 'Name', 'Cfun');
The error message is generated because you have entered a vector instead of a scalar. If you must use a vector to represent a constant function, then you should use the following syntax:
fis = addMF(fis, 'outvar', 'linear', [0, 0, 7], 'Name', 'Cfun');
Strictly speaking, it is incorrect to refer to the outputs of a Sugeno FIS as 'Constant membership function' or 'Linear membership function' because the units of the output values (on the y-axis) of these mathematical functions do not correspond to the membership grades between 0 and 1.
However, the constant function can be reimagined as a Singleton membership function, which is entirely permissible and logically valid.
%% Mamdani Fuzzy System
fis = mamfis;
% Fuzzy Output
fis = addOutput(fis, [6 8], 'Name', 'out');
% fis = addMF(fis, 'out', 'trimf', [7 7 7], 'Name', '7mf'); % transform triMF into a singleton
fis = addMF(fis, 'out', 'gaussmf', [eps 7], 'Name', '7mf'); % approximation, but good enough
plotmf(fis, 'output', 1, 100001), grid on
title('Singleton MF equivalent to a Constant function')

Categories

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

Tags

Community Treasure Hunt

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

Start Hunting!