"Index exceeds matrix dimensions" error when running Fuzzy Inference Engine

1 view (last 30 days)
Hello I have a fuzzy engine, just one input with 4 membership functions and 4 outputs using sugeno type, the result with constant type between [0 10]. I added 4 rules and when i run the engine the error occured index exceeds matrix dimensions. How can i solve this problem.
I have Matlab R2011b
Many Thanks

Answers (1)

Sam Chak
Sam Chak on 9 Apr 2025
The error message likely arises from specifying the membership function parameters as a vector of length two, [0, 10]. However, the parameter of a 'constant'-type singleton membership function must be scalar, as demonstrated in the example below.
%% Fuzzy System
fis = sugfis;
% Fuzzy Input 1
fis = addInput(fis, [-1 +1], 'Name', 'x', 'NumMFs', 4, 'MFType', "gaussmf");
% Fuzzy Output
fis = addOutput(fis, [-1 +1], 'Name', 'y');
% Staircase
fis = addMF(fis, 'y', 'constant', -1.0, 'Name', 'out1');
fis = addMF(fis, 'y', 'constant', -1/3, 'Name', 'out2');
fis = addMF(fis, 'y', 'constant', 1/3, 'Name', 'out3');
fis = addMF(fis, 'y', 'constant', 1.0, 'Name', 'out4');
% Fuzzy Rules
rules = [
"x==mf1 => y=out1"
"x==mf2 => y=out2"
"x==mf3 => y=out3"
"x==mf4 => y=out4"
];
fis = addRule(fis, rules);
figure
plotmf(fis, 'input', 1, 201), grid on, title('Input fuzzy sets')
figure
opt = gensurfOptions('NumGridPoints', 201);
gensurf(fis, opt), title('Fuzzy system output')

Categories

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

Community Treasure Hunt

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

Start Hunting!