% Calculates the end fixity factor given:
%   E0 = scalar, ambient modulus
%   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
%   tauu = (n+1) vector of column upper end tau coefficients

% Updated January 28, 2019 to account for negative values (result of v~=1)
function [ru] = Get_ru_3S_190128(E0,Ic,Lc,RL,RR,tauu)
    % Verify input
    n = length(RL);
    if (length(E0) ~= 1 || ...
            length(Ic) ~= n+1 ||...
            length(Lc) ~= n+1 ||...
            length(RR) ~= length(RL) ||...
            length(tauu)~=n+1)
        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*E0*Ic(i)/Lc(i)/Rij/tauu(i));
        else
            ru(i) = 0;
        end
    end
end