function [thetaout] = theta(flag,Ku,poisu,alpha1,kappa,g,phi,R)

if flag==1
    if alpha1~=0
        thetaout = (4/(3*pi))*(1/Ku)*((1-poisu^2)/(1-2*poisu))*(1/alpha1);
        if isnan(thetaout) || isinf(thetaout)
            disp('THETA1 IS NAN OR INF -> SETTING TO ZERO!')
            thetaout = 0;
        end
    else
        thetaout = 0;
    end
elseif flag==2
    thetaout = (2/(3*Ku))*(((2*(1-poisu^2))/(1-2*poisu))*(((2+kappa)^2+2)/((2+kappa)^2-2))+.5*(1-2*poisu));
    if isnan(thetaout) || isinf(thetaout)
        disp('THETA2 IS NAN OR INF -> SETTING TO ZERO!')
        thetaout = 0;
    end
elseif flag==3
    if g==0 && phi==0
        thetaout = (3/(2*Ku))*((1-poisu)/(1-2*poisu));
        if isnan(thetaout) || isinf(thetaout)
            disp('THETA3(alpha3 = 1) IS NAN OR INF -> SETTING TO ZERO!')
            thetaout = 0;
        end
    else
        d1 = (1-(3*(g+phi)/2-R*((3/2)*g+(5/2)*phi-4/3)));
        d2 = (1-(1+(3/2)*(g+phi)-R*((3/2)*g+(5/2)*phi))+.5*(3-4*R)*(g+phi-R*(g-phi+2*phi^2)))^-1;
        thetaout = Ku^-1*d1*d2;
        if isnan(thetaout) || isinf(thetaout)
            disp('THETA3 IS NAN OR INF -> SETTING TO ZERO!')
        end
    end
end