Plot fuzzy membership function for specified parameters (x, u(x))

조회 수: 16 (최근 30일)
user0002919
user0002919 2019년 5월 26일
답변: Sam Chak 2022년 9월 16일
Since I'm new to Fuzzy Logic and Matlab too, I have two fuzzy subsets and it's membership functions in a picture, and I need to plot the graphs from the membership functions with Matlab. I've already found the waty to plot the graphs, in this doc from Matlab official site: https://www.mathworks.com/help/fuzzy/plotmf.html
But I don't know how to create the .fis file (Fuzzy inference system), containing the fuzzy subsets, just so I can read it in a new code and plot the graph, like in:
fis = readfis('tipper'); #I need to create this.
plot(xOut(:,2),yOut(:,2))
xlabel('food')
ylabel('delicious membership')
Here are the fuzzy subsets I need to transform in a fis file:
And the original set is U = {0, 1, 2, 3, 4, 5, 6, 7, 9}, as seen in the picture.
Please don't send me to a similar question beacause I really need help with this case. What should I do?

답변 (1개)

Sam Chak
Sam Chak 2022년 9월 16일
One proper way to plot the membership functions (MFs) is to create custom MFs based on the given fuzzy sets.
Since this is not possible to save customMF.m online, the Logistic function (aka Sigmoidal MF) from the toolbox can be used to approximate the fuzzy sets.
% Data Sets
u = (0:9)';
A = [0.0 0.0 0.1 0.2 0.3 0.8 0.9 1.0 1.0 1.0]';
B = [1.0 1.0 0.9 0.8 0.7 0.5 0.4 0.2 0.2 0.0]';
% Curve-fitting
fo = fitoptions('Method','NonlinearLeastSquares',...
'Lower',[-10, -10],...
'Upper',[ 10, 10],...
'StartPoint', [1 1]);
ft = fittype('1/(1 + exp(-a*(x - c)))', 'options', fo);
[sigmA, gof] = fit(u, A, ft)
sigmA =
General model: sigmA(x) = 1/(1 + exp(-a*(x - c))) Coefficients (with 95% confidence bounds): a = 1.436 (0.9784, 1.893) c = 4.302 (4.05, 4.554)
gof = struct with fields:
sse: 0.0229 rsquare: 0.9872 dfe: 8 adjrsquare: 0.9855 rmse: 0.0535
[sigmB, gof] = fit(u, B, ft)
sigmB =
General model: sigmB(x) = 1/(1 + exp(-a*(x - c))) Coefficients (with 95% confidence bounds): a = -0.6925 (-0.8296, -0.5554) c = 5.201 (4.888, 5.513)
gof = struct with fields:
sse: 0.0168 rsquare: 0.9858 dfe: 8 adjrsquare: 0.9840 rmse: 0.0459
figure(1)
plot(u, A, '.'), hold on
plot(sigmA, 'r'), hold off
grid on, xlabel('u'), ylabel('A(u)')
legend('Set A', 'Fitted Sigmoid', 'location', 'best')
figure(2)
plot(u, B, '.'), hold on
plot(sigmB, 'r'), hold off
grid on, xlabel('u'), ylabel('B(u)')
legend('Set B', 'Fitted Sigmoid', 'location', 'best')
% Creating FIS and putting the input MFs into FIS
fis = mamfis('Name', "user_FIS");
% Fuzzy Input
fis = addInput(fis, [0 9], 'Name', 'U');
fis = addMF(fis, 'U', 'sigmf', [sigmB.a sigmB.c], 'Name', 'LO');
fis = addMF(fis, 'U', 'sigmf', [sigmA.a sigmA.c], 'Name', 'HI');
% Plot membership functions
figure(3)
plotmf(fis, 'input', 1), grid on, title('U')

카테고리

Help CenterFile Exchange에서 Fuzzy Logic Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by