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

2 ビュー (過去 30 日間)
yasser
yasser 2013 年 11 月 27 日
回答済み: Sam Chak 2025 年 4 月 9 日
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

回答 (1 件)

Sam Chak
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')

カテゴリ

Help Center および File ExchangeFuzzy Logic Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by