function kAPI = getAPIstiffness(phi,kSwitch)
% determine the API recommended subgrade modulus for friction angle input
% NOTE: values are obtained from a figure (approximate)

% convert to degrees
phi = phi*180/pi;

% create list of friction angles
frict = [28.8;
         29.5;
         30.0;
         31.0;
         32.0;
         33.0;
         34.0;
         35.0;
         36.0;
         37.0;
         38.0;
         39.0;
         40.0];
     
% create list of subgrade modulus values
if (kSwitch == 1)
    % subgrade modulus above groundwater table
    k = 271.45*[10;
                23;
                45;
                61;
                80;
                100;
                120;
                140;
                160;
                182;
                215;
                250;
                275];
else
    % subgrade modulus below groundwater table (default)
    k = 271.45*[10;
                20;
                33;
                42;
                50;
                60;
                70;
                85;
                95;
                107;
                122;
                141;
                155];
end

% linear interpolation for friction angles not in list
kAPI = interp1(frict,k,phi);

return