How to train membership functions and rules of the Mamdani FIS
조회 수: 3 (최근 30일)
이전 댓글 표시
I have created a 5-input 1-output mamdani type FIS providing a custom rule-base analyzing the data. The number of MFs and type of MFs is decided depending on the data range and distribution. However, I am unable to find how to train it? Converting my mamdani FIS to sugeno type using mam2sug() does not help.
댓글 수: 0
답변 (1개)
Sam Chak
2025년 4월 16일
Hi @chaks
At the time your question was posted, there was no built-in function in the Fuzzy Logic Toolbox to tune the Mamdani FIS for modeling complex relationships between inputs and outputs, particularly when dealing with imprecise data. The only available tuning method was anfis(), which supports the tuning of type-1 Sugeno FIS with one output variable.
The versatile tunefis() function was later introduced in 2019 and can be used to tune Mamdani FIS, Sugeno FIS, type-2 Mamdani FIS, and type-2 Sugeno FIS based on various tuning algorithms, such as genetic algorithms, particle swarm optimization, pattern search, simulated annealing, and adaptive neuro-fuzzy techniques. Since the R2023b release, it has also been possible to tune membership functions and rule parameters of the FIS tree, which consists of fuzzy systems arranged in hierarchical tree structures.
tic
%% Generate data of a Compounding Bell function
x = linspace(-2, +2, 41)';
y = exp(1)*exp(-cosh(1/2*(3/2*x).^2)); % compounding bell, cbell
y2 = 1/(1 + abs((x)/1).^7); % generalized bell, gbell
%% Set up initial FIS options
opt = genfisOptions('FCMClustering', 'FISType', 'mamdani');
opt.NumClusters = 4;
opt.Verbose = 0;
inifis = genfis(x, y, opt);
[in, out, rule] = getTunableSettings(inifis);
%% Set up tuning method and tune the specified Tunable Settings
options = tunefisOptions('Method', 'ga', 'OptimizationType', 'tuning', 'NumMaxRules', 8, "Display", "none");
options.MethodOptions.MaxGenerations = 60;
outfis = tunefis(inifis, [in; out; rule], x, y, options);
%% Plot results
subplot(2,1,1)
plotmf(outfis, 'input', 1, 1001);
xlabel('Membership Functions for Input 1')
subplot(2,1,2)
plotmf(outfis, 'output', 1, 1001);
xlabel('Membership Functions for Output')
figure
plotrule(outfis)
figure
opt = gensurfOptions('NumGridPoints', 401);
[X, ~, Y] = gensurf(outfis, opt);
plot(x, y), hold on
plot(X, Y), hold off
grid on, ylim([-0.5, 1.5])
legend('Training Data', 'ANFIS Output', 'location', 'best')
xlabel('x'), ylabel('y')
title('Chak Bell')
toc
댓글 수: 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!


