viewing paste Unknown #53141 | Text

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
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
Viewed 429 times, submitted by Guest.