% T = temperatre
% variable == either "fy", "fp" or "Ea" 
% amb_value = ambient value of variable

function [value] = Get_EC3_value(T, variable, amb_value)
    
    % Linearly interpolate from the EC3 table
    Ta = 0.0;
    Tb = 0.0;
    vara = 0.0;
    varb = 0.0;
    
    if (T <= 20)
        Ta = 0;
        Tb = 20;
        if (variable == "fy")
            vara = 1;
            varb = 1;
        elseif (variable == "fp")
            vara = 1;
            varb = 1;
        elseif (variable == "Ea")
            vara = 1;
            varb = 1;
        end
    elseif (T <= 100)
        Ta = 20;
        Tb = 100;
        if (variable == "fy") 
            vara = 1;
            varb = 1;
        elseif (variable == "fp") 
            vara = 1;
            varb = 1;
        elseif (variable == "Ea") 
            vara = 1;
            varb = 1;
        end
    elseif (T <= 200) 
        Ta = 100;
        Tb = 200;
        if (variable == "fy") 
            vara = 1;
            varb = 1;
        elseif (variable == "fp") 
            vara = 1;
            varb = 0.807;
        elseif (variable == "Ea") 
            vara = 1;
            varb = 0.9;
        end
    elseif (T <= 300) 
        Ta = 200;
        Tb = 300;
        if (variable == "fy") 
            vara = 1;
            varb = 1;
        elseif (variable == "fp") 
            vara = 0.807;
            varb = 0.613;
        elseif (variable == "Ea") 
            vara = 0.9;
            varb = 0.8;
        end
    elseif (T <= 400) 
        Ta = 300;
        Tb = 400;
        if (variable == "fy") 
            vara = 1;
            varb = 1;
        elseif (variable == "fp")
            vara = 0.613;
            varb = 0.42;
        elseif (variable == "Ea") 
            vara = 0.8;
            varb = 0.7;
        end
    elseif (T <= 500) 
        Ta = 400;
        Tb = 500;
        if (variable == "fy") 
            vara = 1;
            varb = 0.78;
        elseif (variable == "fp") 
            vara = 0.42;
            varb = 0.36;
        elseif (variable == "Ea") 
            vara = 0.7;
            varb = 0.6;
        end
    elseif (T <= 600) 
        Ta = 500;
        Tb = 600;
        if (variable == "fy") 
            vara = 0.78;
            varb = 0.47;
        elseif (variable == "fp") 
            vara = 0.36;
            varb = 0.18;
        elseif (variable == "Ea") 
            vara = 0.6;
            varb = 0.31;
        end
    elseif (T <= 700) 
        Ta = 600;
        Tb = 700;
        if (variable == "fy") 
            vara = 0.47;
            varb = 0.23;
        elseif (variable == "fp") 
            vara = 0.18;
            varb = 0.075;
        elseif (variable == "Ea") 
            vara = 0.31;
            varb = 0.13;
        end
    elseif (T <= 800) 
        Ta = 700;
        Tb = 800;
        if (variable == "fy") 
            vara = 0.23;
            varb = 0.11;
        elseif (variable == "fp") 
            vara = 0.075;
            varb = 0.05;
        elseif (variable == "Ea") 
            vara = 0.13;
            varb = 0.09;
        end
    elseif (T <= 900) 
        Ta = 800;
        Tb = 900;
        if (variable == "fy") 
            vara = 0.11;
            varb = 0.06;
        elseif (variable == "fp") 
            vara = 0.05;
            varb = 0.0375;
        elseif (variable == "Ea") 
            vara = 0.09;
            varb = 0.0675;
        end
    elseif (T <= 1000) 
        Ta = 900;
        Tb = 1000;
        if (variable == "fy") 
            vara = 0.06;
            varb = 0.04;
        elseif (variable == "fp") 
            vara = 0.0375;
            varb = 0.025;
        elseif (variable == "Ea") 
            vara = 0.0675;
            varb = 0.045;
        end
    elseif (T <= 1100) 
        Ta = 1000;
        Tb = 1100;
        if (variable == "fy") 
            vara = 0.04;
            varb = 0.02;
        elseif (variable == "fp") 
            vara = 0.025;
            varb = 0.0125;
        elseif (variable == "Ea") 
            vara = 0.045;
            varb = 0.0225;
        end
    elseif (T <= 1200) 
        Ta = 1100;
        Tb = 1200;
        if (variable == "fy") 
            vara = 0.02;
            varb = 0;
        elseif (variable == "fp") 
            vara = 0.0125;
            varb = 0;
        elseif (variable == "Ea") 
            vara = 0.0225;
            varb = 0;
        end
    else
        Ta = 1200;
        Tb = 1000000;
        vara = 0;
        varb = 0;
    end
    
    k = vara + (varb - vara) * (T - Ta) / (Tb - Ta);
    value = amb_value * k;
    
end