Filter löschen
Filter löschen

Membership function not plotting right

5 Ansichten (letzte 30 Tage)
Juan Lopez
Juan Lopez am 19 Aug. 2021
Beantwortet: Sam Chak am 21 Sep. 2024 um 14:13
Hi,
I am creating a triangular membership function (MF) that can be parametrized. A FOR loop is used to construct all the MF.
for j=1:num_MF_input
a=LB+(Base_input*j/2-Base_input/2);
fis = addMF(fis,Name_1D_in,"trimf",[a a+Base_input/2 a+Base_input], ...
'Name',name_MF_input(j));
end
Where num_MF_input is the number of MF, LB is the Lower Boundary of my MF domain, and Base_input is the lenght of the triangle's base.
This seems to work fine when I see the properties of the MF and the parameters (base-tip-base) are as desired (First Figure).
However, when plotting the same MF, there seems to be errors in the tips of some MF, and also in the base.
Would this be just a plotting error and I should not worry since the parameters are right? Or why does this happens?
Thanks.

Antworten (1)

Sam Chak
Sam Chak am 21 Sep. 2024 um 14:13
Specifying the number of data points (numPoints) in the 'plofmf' command to plot for each MF will solve the problem.
%% Parameters
num_MF_input = 7;
LB = -8;
Base_input = 4;
numPoints = 201;
%% Create a Mamdani FIS object named "Fuzzy_Lopez"
fis = mamfis("Name", "Fuzzy_Lopez");
%% Add an Input variable named "Name_1D_in"
fis = addInput(fis, [LB -LB], "Name", "Name_1D_in");
%% Automate the creation the fuzzy sets
for j=1:num_MF_input
a = LB + (Base_input*j/2 - Base_input/2);
fis = addMF(fis, "Name_1D_in", "trimf", [a a+Base_input/2 a+Base_input]);
end
%% Plot input fuzzy sets
plotmf(fis, 'input', 1, numPoints), grid on, grid minor

Kategorien

Mehr zu Fuzzy Logic Toolbox finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by