كود لرسم الدالة Trapezoidal Fuzzy Sets A and B

كود لرسم الدالة Trapezoidal Fuzzy Sets A and B

x=0:0.25:7;
a=0.5;
b=1.5;
c=2.5;
d=4;

f=min((x-a)/(b-a),(d-x)/(d-c));
g=min(f,1);
h=max(0,g);

plot(x,h, '.-k','LineWidth',3)
hold on;

x=0:0.25:7;
a=2.5;
b=4;
c=5;
d=6.5;

f=min((x-a)/(b-a),(d-x)/(d-c));
g=min(f,1);
h=max(0,g);

plot(x,h, '.-b','LineWidth',3)
axis([0, 7, -0.05, 1.05 ]);
title('Trapezoidal Fuzzy Sets A and B');
grid on;
hold off;