% To generate curves presented in Figure 3 (B) of the main text, choose one of % the values of delta (the fitness of drug-resistance) clear all clc %% System parameters with units in days delta=0.38; % fitness of drug-resistance for first curve %delta=0.42; % fitness of drug-resistance for second curve %delta=0.46; % fitness of drug-resistance for third curve mu=1/(70*365); gamma=1/(5); R0=3; beta=R0*(mu+gamma); betar=delta*beta; R3=delta*R0; hh=0.000005; % steps of increments for delay %% initial conditions I0 = 0.001; Ir0 = 0.0001; S0 = 1-I0-Ir0; taustar=-log(1-1/R0)/(mu+gamma) % delay when R1=1 tau0=-log(1-delta)/(mu+gamma) % delay when R1=R3 %% curves of endemic state for ii=1:ceil(1/gamma/hh) xx(ii)=1-1/R3; tau(ii)=ii*hh; if tau(ii)