x1=-4:0.1:4;
%======temp======start======
A1=(1-(x1+4)/4).*(x1>=-4&x1<0);
A2=((x1+2)/2).*(x1>-2&x1<0)+...
(1-x1/2).*(x1>=0&x1<2);
A3=x1/4.*(x1>0&x1<=4);
%======temp======end======
x2=0:0.1:8;
%======weight======start======
B1=(1-x2/4).*(x2>=0&x2<4);
B2=((x2-2)/2).*(x2>2&x2<4)+...
(1-(x2-4)/2).*(x2>=4&x2<6);
B3=(x2-4)/4.*(x2>4&x2<=8);
%======weight======end======
y2=600:0.1:1200;
%======power======start======
C1=(1-(y2-600)/200).*(y2>=600&y2<800);
C2=((y2-700)/200).*(y2>700&y2<900)+...
(1-(y2-900)/200).*(y2>=900&y2<1100);
C3=(y2-1000)/200.*(y2>1000&y2<=1200);
%======power======end======
y1=0:0.1:10;
%======time======start======
D1=(1-y1/5).*(y1>=0&y1<5);
D2=(y1/5).*(y1>0&y1<5)+...
(1-(y1-5)/5).*(y1>=5&y1<10);
D3=(y1-5)/5.*(y1>5&y1<=10);
%======time======end======
C11=min(C1,min(A3(temperature),B3(weight)));
C12=min(C1,min(A3(temperature),B2(weight)));
C13=min(C1,min(A3(temperature),B1(weight)));
C21=min(C2,min(A2(temperature),B3(weight)));
C22=min(C2,min(A2(temperature),B2(weight)));
C23=min(C2,min(A2(temperature),B1(weight)));
C31=min(C3,min(A1(temperature),B3(weight)));
C32=min(C3,min(A1(temperature),B2(weight)));
C33=min(C3,min(A1(temperature),B1(weight)));
C1=max(C11,max(C12,C13));
C2=max(C21,max(C22,C23));
C3=max(C31,max(C32,C33));
C=max(C1,max(C2,C3));
D11=min(D1,min(B1(weight),A3(temperature)));
D12=min(D1,min(B1(weight),A2(temperature)));
D13=min(D1,min(B1(weight),A1(temperature)));
D21=min(D2,min(B2(weight),A3(temperature)));
D22=min(D2,min(B2(weight),A2(temperature)));
D23=min(D2,min(B2(weight),A1(temperature)));
D31=min(D3,min(B3(weight),A3(temperature)));
D32=min(D3,min(B3(weight),A2(temperature)));
D33=min(D3,min(B3(weight),A1(temperature)));
D1=max(D11,max(D12,D13));
D2=max(D21,max(D22,D23));
D3=max(D31,max(D32,D33));
D=max(D1,max(D2,D3));
%======defuzzifier======COG======start======
temp=0;
for i=1:6001
temp=temp+y1(i)*C(i);
end
power=temp/sum(C);
temp=0;
for i=1:101
temp=temp+y2(i)*D(i);
end
time=temp/sum(D);
%======defuzzifier======COG======end======