fuzzy logic
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I creatd my varibles (inputs) and my ouput( one output), each varibles has fuzzy memberships, for example for I have "security stability" as varible wich include fuzzy 0=poor,0.5=good,0.7=verygood. another example "type of agreement" (0=.2=weak,0.5=good,0.7=very good,0.8=strong,0.9=verystrong,1= excellent)how can i add this memberships in the parameter? which syntax I have to use,are these concider as parameters?which range I have to use? which shape? shall I use gaussmf or traingle or zmf? thank you so much
0 comentarios
Respuestas (1)
Sam Chak
el 7 de Abr. de 2025
Traditionally, trimf and gaussmf are the two most commonly used membership functions in fuzzy systems. However, if the centers of the fuzzy sets are not uniformly distributed over the variable range, it may be more appropriate to use piecewise functions such as trapmf or gauss2mf to flexibly connect adjacent fuzzy sets at the desired crossover points. However, an excessive number of trimf or trapmf functions can result in a fuzzy surface that resembles the Grand Canyon. Therefore, if a smooth surface is desired, gaussmf or gauss2mf are generally recommended.
fis = mamfis;
%% Fuzzy Input #1
c11 = 0.0; % center of MF1 (poor)
c12 = 0.5; % center of MF2 (good)
c13 = 0.7; % center of MF3 (very good)
cross = 0.5; % crossover point where the deg of MF μ(x) equals to 0.5
dist11 = c12 - c11;
sigma11 = 0.5*(dist11)/sqrt(-2*log(cross)); % std dev 1
dist12 = c13 - c12;
sigma12 = 0.5*(dist12)/sqrt(-2*log(cross)); % std dev 2
fis = addInput(fis, [c11 c13], 'Name', 'SecurityStability');
fis = addMF(fis, 'SecurityStability', 'gaussmf', [sigma11 c11], 'Name', 'Poor');
fis = addMF(fis, 'SecurityStability', 'gauss2mf', [sigma11 c12 sigma12 c12], 'Name', 'Good');
fis = addMF(fis, 'SecurityStability', 'gaussmf', [sigma12 c13], 'Name', 'VeryGood');
%% Fuzzy Input #2
c21 = 0.2;
c22 = 0.5;
c23 = 0.7;
c24 = 0.8;
c25 = 0.9;
c26 = 1.0;
dist21 = c22 - c21;
sigma21 = 0.5*(dist21)/sqrt(-2*log(cross));
dist22 = c23 - c22;
sigma22 = 0.5*(dist22)/sqrt(-2*log(cross));
dist23 = c24 - c23;
sigma23 = 0.5*(dist23)/sqrt(-2*log(cross));
fis = addInput(fis, [0.0 c26], 'Name', 'TypeOfAgreement');
fis = addMF(fis, 'TypeOfAgreement', 'gauss2mf', [sigma21 0.0 sigma21 c21], 'Name', 'Weak');
fis = addMF(fis, 'TypeOfAgreement', 'gauss2mf', [sigma21 c22 sigma22 c22], 'Name', 'Good');
fis = addMF(fis, 'TypeOfAgreement', 'gauss2mf', [sigma22 c23 sigma23 c23], 'Name', 'VG');
fis = addMF(fis, 'TypeOfAgreement', 'gaussmf', [sigma23 c24], 'Name', 'Strong');
fis = addMF(fis, 'TypeOfAgreement', 'gaussmf', [sigma23 c25], 'Name', 'VS');
fis = addMF(fis, 'TypeOfAgreement', 'gaussmf', [sigma23 c26], 'Name', 'Exc');
%% Fuzzy Output
in1nMFs = numel(fis.Inputs(1).MembershipFunctions);
in2nMFs = numel(fis.Inputs(2).MembershipFunctions);
outnMFs = in1nMFs + in2nMFs - 1;
fis = addOutput(fis, [1 outnMFs], 'Name', 'Index', 'NumMFs', outnMFs, 'MFType', "gaussmf");
%% Fuzzy Rules
rules = [
"SecurityStability==Poor & TypeOfAgreement==Weak => Index=mf1"
"SecurityStability==Poor & TypeOfAgreement==Good => Index=mf2"
"SecurityStability==Poor & TypeOfAgreement==VG => Index=mf3"
"SecurityStability==Poor & TypeOfAgreement==Strong => Index=mf3"
"SecurityStability==Poor & TypeOfAgreement==VS => Index=mf4"
"SecurityStability==Poor & TypeOfAgreement==Exc => Index=mf4"
"SecurityStability==Good & TypeOfAgreement==Weak => Index=mf3"
"SecurityStability==Good & TypeOfAgreement==Good => Index=mf3"
"SecurityStability==Good & TypeOfAgreement==VG => Index=mf4"
"SecurityStability==Good & TypeOfAgreement==Strong => Index=mf5"
"SecurityStability==Good & TypeOfAgreement==VS => Index=mf6"
"SecurityStability==Good & TypeOfAgreement==Exc => Index=mf6"
"SecurityStability==VeryGood & TypeOfAgreement==Weak => Index=mf4"
"SecurityStability==VeryGood & TypeOfAgreement==Good => Index=mf5"
"SecurityStability==VeryGood & TypeOfAgreement==VG => Index=mf6"
"SecurityStability==VeryGood & TypeOfAgreement==Strong => Index=mf6"
"SecurityStability==VeryGood & TypeOfAgreement==VS => Index=mf7"
"SecurityStability==VeryGood & TypeOfAgreement==Exc => Index=mf8"
];
fis = addRule(fis, rules);
%% Plot figures
figure
tL = tiledlayout(2, 1, 'TileSpacing', 'Compact');
nexttile
numpts1 = (c13 - c11)*1000 + 1;
plotmf(fis, 'input', 1, numpts1), grid on, title('Input 1 fuzzy sets')
nexttile
numpts2 = (c26 - 0.0)*1000 + 1;
plotmf(fis, 'input', 2, numpts2), grid on, title('Input 2 fuzzy sets')
figure
numpts3 = (outnMFs - 1)*100 + 1;
plotmf(fis, 'output', 1, numpts3), grid on, title('Output fuzzy sets')
figure
opt = gensurfOptions('NumGridPoints', 51);
gensurf(fis, opt), title('Fuzzy decision surface')
0 comentarios
Ver también
Categorías
Más información sobre Fuzzy Logic Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


