Wednesday, 13 January 2016

Implement fuzzy membership functions (triangular, trapezoidal, gbell, PI, Gamma, Gaussian) ......... MATLAB Code

clc;
clear all;
close all;

ip=input('Enter input range : ');
a=input('Enter value of alpha : ');
b=input('Enter value of beta : ');
c=input('Enter value of gamma : ');
d=input('Enter value of delta : ');
m=input('Enter value of m : ');
del=input('Enter value of del : ');

%Gamma function

for u=1:ip
    if(u<=a)
        g(u)=0;
    elseif((u>a)&&(u<=b))
        g(u)=((u-a)/(b-a));
    else
        g(u)=1;
    end
end

subplot(2,3,1)
plot(g)
title('Gamma Function')
axis([0 ip 0 1]);

%S function

for u=1:ip
    if(u<=a)
        s(u)=0;
    elseif((u>a)&&(u<=b))
        s(u)=2*(((u-a)/(c-a))^2);
    elseif((u>b)&&(u<=c))
        s(u)=1-(2*(((u-c)/(c-a))^2));
    else
        s(u)=1;
    end
end


subplot(2,3,2)
plot(s);
title('S Function');
axis([0 ip 0 1]);

%Triangular function

for u=1:ip
    if(u<=a)
        t(u)=0;
    elseif((u>a)&&(u<=b))
        t(u)=((u-a)/(b-a));
    elseif((u>b)&&(u<=c))
        t(u)=((c-u)/(c-b));
    else
        t(u)=0;
    end
end

subplot(2,3,3)
plot(t);
title('Triangular Function');
axis([0 ip 0 1]);

%Pie function

for u=1:ip
    if(u<=a)
        p(u)=0;
    elseif((u>a)&&(u<=b))
        p(u)=((u-a)/(b-a));
    elseif((u>b)&&(u<=c))
        p(u)=1;
    elseif((u>c)&&(u<=d))
        p(u)=((d-u)/(d-c));
    else
        p(u)=0;
    end
end

subplot(2,3,4)
plot(p);
title('Pie Function');
axis([0 ip 0 1]);

%Gaussian function

for u=1:ip
   gs(u)=exp((-((u-m)^2))/(2*(del^2)));
end

subplot(2,3,5)
plot(gs);
title('Gaussian Function');
axis([0 ip 0 1]);

No comments:

Post a Comment