"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!