function [EC50] = 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

    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
    b(4) = 0; %Hill coefficient
    Beta = nlinfit(Rap_conc_uM, Tm, modelfun, b);

    RapConc2 = [0.0001,0.001, 0.005, 0.01, 0.05,0.08, 0.1,0.3, 0.5,0.8,0.9,1,1.5,2, 3, 5,8, 10, 50];

    Fitdata = modelfun(Beta, RapConc2);
    figure
    semilogx(RapConc2, Fitdata, '-', Rap_conc_uM, Tm,'*')
    legend('EC50 curve fit', 'Actual data')
    xlabel('Rapmaycin concentration (uM)')
    ylabel('Tm')

    EC50 = Beta(3)
end