%Sample solution for problem 24 on page 24 of the text book
%initialize the Rs and Rl vector
Rs = [10, 15, 20, 25];
Rl = [10, 15, 20, 25, 30];

%calculate the length of both vectors
L1 = length(Rs);

%first level of loop, go throught all the source resistence 
for i = 1:1:L1
    %that is the source resistence we consider in this loop
    given_r = Rs(i)
    
    %calculate the ratio value for each pair of (source resistence,
    %load resistence) and put them in the vector V
    V = Rl./(Rs(i)+Rl).^2;
    
    %find the max ratio and its index
    [x, k] = max(V);
    
    %that is the best load resistence for the given source resistence
    P(i) = Rl(k);
    R(i) = x;     % the maximized ratio
end

%prepare the final results
T = cat (1, Rs, P, R)
