function [Kd] = EC50(Rap_conc_uM, Tm)
    %This function takes in an array of Rapamycin concentrations and an array
    %of corresponding Tms from DSF
    %Expects all concentrations to be in uM
    %Returns EC50 value in uM

%     P = 8.5; %uM initial protein concentration
    modelfun = @(b, X)(b(1) + ((b(2)-b(1))./(1+((X./b(3)).^(-1*b(4))))));
    b(1) = min(Tm);%bottom
    b(2) = max(Tm);%top
    b(3) = 1; %EC50, Rap concentration ~mean of top and bottom
    b(4) = 0; %Hill coefficient
    Beta = nlinfit(Rap_conc_uM, Tm, modelfun, b);

    % RapConc = [0.0001,0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 5, 10, 20];

    Fitdata = modelfun(Beta, Rap_conc_uM);
    figure
    semilogx(Rap_conc_uM, Fitdata, '-', Rap_conc_uM, Tm,'*')
    legend('Single site binding model', 'Actual data')
    xlabel('Rapmaycin concentration (uM)')
    ylabel('Tm')

    Kd = Beta(3)
end