clc;
clear all;
close all;
ip=11;
a1=1;
a2=5;
b1=4;
b2=7;
c1=7;
c2=9;
d2=11;
s1=0;
s2=0;
%Triangular function
for u=1:ip
if(u<=a1)
t(u)=0;
elseif((u>a1)&&(u<=b1))
t(u)=((u-a1)/(b1-a1));
elseif((u>b1)&&(u<=c1))
t(u)=((c1-u)/(c1-b1));
else
t(u)=0;
end
end
subplot(221)
plot(t);
title('Triangular Function');
%Pie function
for u=1:ip
if(u<=a2)
p(u)=0;
elseif((u>a2)&&(u<=b2))
p(u)=((u-a2)/(b2-a2));
elseif((u>b2)&&(u<=c2))
p(u)=1;
elseif((u>c2)&&(u<=d2))
p(u)=((d2-u)/(d2-c2));
else
p(u)=0;
end
end
subplot(222)
plot(p);
title('Pie Function');
z=t+p;
subplot(223);
plot(z);
%Using Centroid Method
for i=1:11
s1=s1+(z(i)*i);
s2=s2+z(i);
end
op1=s1/s2;
disp('Using Centroid Method:');
disp(op1);
%Using Weighted average method
a=mean(ip);
s1=s1+t(a)*(a)+p(a)*(a);
s2=s2+z(a)+p(a);
op1=s1/s2;
disp('Using Weighted Average MEthod');
disp(op1);
%Using Max-Membership Principle
k=z(1);
m=1;
for i=2:ip
if(k<z(i))
k=z(i);
m=i;
end
end
disp('Using Max Membership principle');
disp(m);
clear all;
close all;
ip=11;
a1=1;
a2=5;
b1=4;
b2=7;
c1=7;
c2=9;
d2=11;
s1=0;
s2=0;
%Triangular function
for u=1:ip
if(u<=a1)
t(u)=0;
elseif((u>a1)&&(u<=b1))
t(u)=((u-a1)/(b1-a1));
elseif((u>b1)&&(u<=c1))
t(u)=((c1-u)/(c1-b1));
else
t(u)=0;
end
end
subplot(221)
plot(t);
title('Triangular Function');
%Pie function
for u=1:ip
if(u<=a2)
p(u)=0;
elseif((u>a2)&&(u<=b2))
p(u)=((u-a2)/(b2-a2));
elseif((u>b2)&&(u<=c2))
p(u)=1;
elseif((u>c2)&&(u<=d2))
p(u)=((d2-u)/(d2-c2));
else
p(u)=0;
end
end
subplot(222)
plot(p);
title('Pie Function');
z=t+p;
subplot(223);
plot(z);
%Using Centroid Method
for i=1:11
s1=s1+(z(i)*i);
s2=s2+z(i);
end
op1=s1/s2;
disp('Using Centroid Method:');
disp(op1);
%Using Weighted average method
a=mean(ip);
s1=s1+t(a)*(a)+p(a)*(a);
s2=s2+z(a)+p(a);
op1=s1/s2;
disp('Using Weighted Average MEthod');
disp(op1);
%Using Max-Membership Principle
k=z(1);
m=1;
for i=2:ip
if(k<z(i))
k=z(i);
m=i;
end
end
disp('Using Max Membership principle');
disp(m);
No comments:
Post a Comment