% Calculates the end fixity factor given:
%   Ec = (n+1) vector of column moduli
%   Ic = (n+1) vector of column inertia
%   Lc = (n+1) vector of column lengths
%   RL = (n) vector of beam left end rotational stiffness
%   RR = (n) vector of beam right end rotational stiffness
function [ru] = Get_ru(Ec,Ic,Lc,RL,RR)
    % Verify input
    n = length(RL);
    if (length(Ec) ~= n+1 || ...
            length(Ic) ~= n+1 ||...
            length(Lc) ~= n+1 ||...
            length(RR) ~= length(RL))
        ru = -100;
        return;
    end
    
    ru = zeros(1,n+1);
    for i = 1:n+1
        Rij = 0;
        if (i~=n+1)
            Rij = Rij + RL(i);
        end
        if (i~=1)
            Rij = Rij + RR(i-1);
        end
        if (Rij>0)
            ru(i) = 1/(1+3*Ec(i)*Ic(i)/Lc(i)/Rij);
        else
            ru(i) = 0;
        end
    end
end