Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc; clear;
- ZX = zeros(4, 101);
- ZY = zeros(4, 101);
- A0 = zeros(5, 101);
- a = 0;
- b = 0;
- for i = 1:101
- x = (i-1)/2;
- ZX(1,i) = x;
- if x <= 20
- uA = 1;
- elseif x >= 20 & x <= 30
- uA=(30-x) / (30-20);
- else
- uA = 0;
- end
- ZX(2,i) = uA;
- if x <= 20 then
- uB = 0;
- elseif x <= 30 & x >= 20
- uB = (x-20) / (30-20);
- elseif x == 30
- uB = 1
- elseif x >= 30 & x <= 40
- uB = (40-x) / (40-30);
- else
- uB = 0;
- end
- ZX(3,i) = uB;
- if x <= 30 then
- uC = 0;
- elseif x >= 30 & x <= 40
- uC=(x-30) / (40-30);
- else
- uC = 1;
- end
- ZX(4,i)=uC;
- end
- //podpunkt B
- for i=1:101
- x=i-1;
- ZY(1,i)=x;
- A0(1,i)=x;
- if x >= 0 & x <= 50
- uD=(50-x) / (50-0);
- else
- uD = 0;
- end
- ZY(2,i) = uD;
- if x <= 20 then
- uE = 0;
- elseif x <= 60 & x >= 20
- uE=(x-20) / (60-20);
- elseif x <= 80 & x >= 60
- uE= (80-x) / (80-60);
- end
- ZY(3,i)=uE;
- if x <= 60 then
- uF = 0;
- elseif x <= 100 & x >= 60
- uF= (x-60) / (100-60);
- else x <= 100
- uF = 1;
- end
- ZY(4,i) = uF;
- end
- subplot(5,1,1)
- plot(ZX(1,:), ZX(2,:));
- plot(ZX(1,:), ZX(3,:));
- plot(ZX(1,:), ZX(4,:));
- mtlb_axis([0 50 0 1.2])
- subplot(5,1,2)
- plot(ZY(1,:), ZY(2,:));
- plot(ZY(1,:), ZY(3,:));
- plot(ZY(1,:), ZY(4,:));
- mtlb_axis([0 100 0 1.2])
- //podpunkt c
- xx = input("podaj zmienna lingwistyczna: ");
- xx = 2*xx+1;
- uA = ZX(2,xx);
- uB = ZX(3,xx);
- uC = ZX(4,xx);
- //podpunkt d
- for i=1:101
- //R1
- if uA>0 then A0(2,i) = min(uA, ZY(2,i)); end
- //R2
- if uB>0 then A0(3,i) = min(uB, ZY(3,i)); end
- //R3
- if uC>0 then A0(4,i) = min(uC, ZY(4,i)); end
- end
- disp(xx);
- subplot(5,1,3);
- plot(A0(1,:),A0(2,:),"r");
- plot(A0(1,:),A0(3,:),"g");
- plot(A0(1,:),A0(4,:),"b");
- mtlb_axis([0 100 0 1.2]);
- //podpunkte
- for i=1:101
- A0(5,i)=max(A0(2,i),A0(3,i),A0(4,i));
- end
- subplot(4,1,4);
- plot(A0(1,:),A0(5,:),"r");
- mtlb_axis([0 100 0 1.2]);
- //podpunkt f
- for i=1:101
- a=a+A0(1,i)*A0(5,i)
- b=b+A0(5,i)
- end
- y=a/b;
- disp(y);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement