abs = [0:0.1:30]; a=A(abs); b=B(abs); cb = comp(b); hold on plot(abs,a); plot(abs,b); plot(abs,union(a,b)); hold off figure hold on plot(abs,a); plot(abs,b); plot(abs,inter(a,b)); hold off figure hold on plot(abs,b); plot(abs,cb); hold off figure hold on plot(abs,a); plot(abs,cb); plot(abs,inter(a,cb)); hold off function ua = A(x) ua=[1:300]; for i= 1:length(x) n=x(i); if n<7 un = 0; else un = (n-7)/(n-5); end ua(i)=un; end end function ub = B(x) ub = 1./(1+(x-12).^2); end function AuB = union(A,B) if length(A) ~= length(B) ME = MException("Union:wrongArraySize","The sizes of the two arrays do not match"); throw(ME); end AuB = max(A,B); end function AnB = inter(A,B) if length(A) ~= length(B) ME = MException("Union:wrongArraySize","The sizes of the two arrays do not match"); throw(ME); end AnB=min(A,B); end function cA = comp(A) cA=1-A; end