How to create membership functions matlab in triangular form?

5 visualizaciones (últimos 30 días)
mindo akami
mindo akami el 9 de Jun. de 2021
Editada: Sam Chak el 22 de Mzo. de 2022
Hi, hoping somone can help
i add the rule 1 and 2 with trimf function but how can i plot the rule 3 and 4 pleas (see the attched images) thanks )

Respuestas (2)

darova
darova el 9 de Jun. de 2021
Use sine wave
x = 0:pi/2:20;
y = sin(x);
plot(x,y)
  2 comentarios
mindo akami
mindo akami el 9 de Jun. de 2021
Hi, thanks for your answer darova
but if we take the image closely the rule 3 for example is like this and i don't know how to do it
darova
darova el 24 de Jul. de 2021
Maybe manual solution?
x = [-180 -90 -90 90 90 180];
y = abs(sind(x));
y(3:4) = 0;
plot(x,y)

Iniciar sesión para comentar.


Sam Chak
Sam Chak el 22 de Mzo. de 2022
Editada: Sam Chak el 22 de Mzo. de 2022
You probably have already learned the manual way to plot these. Since this is unanswered and if you are still interested in learning to plot the 'fuzzy way', here is the code:
x = -180:0.1:180; % set the domain of discourse
y1 = trimf(x,[-90 0 90]); % Rule 1
y2 = 1 - y1; % Rule 2
y3 = trimf(x,[-180 -90 -90]) + trimf(x,[90 90 180]); % Rule 3
y4 = trimf(x,[-180 -180 -90]) + trimf(x,[90 180 180]); % Rule 4
h = plot(x, y1, 'r-', x, y2, 'g-', x, y3, 'b-', x, y4, 'm-');
set(h, 'LineWidth', 1.5)
xticks([-180 -90 0 90 180]);
xlabel('x_{1}, (degree)');
ylabel('Degree of Membership, \mu');
The line colors follow the original image that you posted here:
Result:

Categorías

Más información sobre Fuzzy Logic Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by