"Index exceeds matrix dimensions" error when running Fuzzy Inference Engine
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
Sam Chak
2025-4-9
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')
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fuzzy Logic Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!