close

flag1=0;
flag2=0;
flag3=0;
flag4=0;
flag5=0;
var1=0;
var2=0;
var3=0;
var4=0;
var5=0;

while(flag1==0)
    var1 = input('Enter a value for the source term s: ');
    if(var1>0)
        s=var1;
        flag1=1;
    else
        disp('        ')
        disp('ERROR: s must be positive.')
        disp('        ')
    end
end
flag1=0;
disp('          ')
while(flag1==0)
    var1 = input('Enter a value for natural death rate of T cells (m_1): ');
    if(var1>0)
        m1=var1;
        flag1=1;
    else
        disp('        ')
        disp('ERROR: m_1 must be positive.')
        disp('        ')
    end
end
flag1=0;
disp('          ')
while(flag1==0)
    var1 = input('Enter a value for death rate of infected T cells (m_2): ');
    if(var1>0)
        m2=var1;
        flag1=1;
    else
        disp('        ')
        disp('ERROR: m_2 must be positive.')
        disp('        ')
    end
end
flag1=0;
disp('          ')
while(flag1==0)
    var1 = input('Enter a value for viral death rate (m_3): ');
    if(var1>0)
        m3=var1;
        flag1=1;
    else
        disp('        ')
        disp('ERROR: m_3 must be positive.')
        disp('        ')
    end
end
flag1=0;
disp('          ')
while(flag1==0)
    var1 = input('Enter a value for the T cell growth rate (r): ');
    if(var1>0)
        r=var1;
        flag1=1;
    else
        disp('        ')
        disp('ERROR: r must be positive.')
        disp('        ')
    end
end
flag1=0;
disp('          ')
while(flag1==0)
    var1 = input('Enter a maximum T cell level (T_max): ');
    if(var1>0)
        Tmax = var1;
        flag1=1;
    else
        disp('        ')
        disp('ERROR: T_max must be positive.')
        disp('        ')
    end
end
flag1=0;
disp('          ')
while(flag1==0)
    var1 = input('Enter a value for infection rate (k): ');
    if(var1>0)
        k = var1;
        flag1=1;
    else
        disp('        ')
        disp('ERROR: k must be positive.')
        disp('        ')
    end
end
flag1=0;
disp('          ')
while(flag1==0)
    var1 = input('Enter the average number of virus cells produced (N): ');
    if(var1>0)
        N = var1;
        flag1=1;
    else
        disp('        ')
        disp('ERROR: N must be positive.')
        disp('        ')
    end
end
flag1=0;
disp('          ')
while(flag1==0)
    var1 = input('Enter an initial uninfected T cell concentration (T_0): ');
    if(var1>0)
        T0 = var1;
        flag1=1;
    else
        disp('        ')
        disp('ERROR: T_0 must be positive.')
        disp('        ')
    end
end
flag1=0;
disp('          ')
while(flag1==0)
    var1 = input('Enter an initial infected T cell concentration (T_i0): ');
    if(var1>0)
        Ti0 = var1;
        flag1=1;
    else
        disp('        ')
        disp('ERROR: T_i0 must be positive.')
        disp('        ')
    end
end
flag1=0;
disp('          ')
while(flag1==0)
    var1 = input('Enter an initial free virus concentration (V_0): ');
    if(var1>0)
        V0 = var1;
        flag1=1;
    else
        disp('        ')
        disp('ERROR: V_0 must be positive.')
        disp('        ')
    end
end
flag1=0;
disp('          ')
while(flag1==0)
    var1 = input('Enter a value for the weight parameter B: ');
    if(var1>0)
        B = var1;
        flag1=1;
    else
        disp('        ')
        disp('ERROR: B must be positive.')
        disp('        ')
    end
end
flag1=0;
disp('          ')
while(flag1==0)
    var1 = input('Enter the number of days you would like to run this model (t_final): ');
    if(0<var1);
        time=var1;
        flag1=1;
    else
        disp('            ')
        disp('ERROR: t_f must be positive.')
        disp('            ')
    end
end
disp('           ')
disp('One moment please...')
y1=labnine(s,m1,m2,m3,r,Tmax,k,N,T0,Ti0,V0,B,time);

disp('               ')

while(flag3==0)
    disp('Would you like to plot')
    disp('   1. Uninfected T cell concentration (T)')
    disp('   2. Infected T cell concentration (T_i)')
    disp('   3. Free virus concentration (V)')
    disp('   4. Chemotherapy rate (u)')
    disp('   5. all four')
    var3=input('Type 1, 2, 3, 4, or 5: ');

    if((var3==1) | (var3==2) | (var3==3) | (var3==4) | (var3==5))
        flag3=1;
        disp('         ')
        while(flag4==0)
            disp('Would you like to vary any parameters?')
            disp('1. Yes')
            disp('2. No')
            var4=input('Type 1 or 2: ');
            
            if(var4==1)
                disp('         ')
                flag4=1;
                while(flag5==0)
                    disp('Which parameter would you like to vary?')
                    disp('1. s')
                    disp('2. m_1')
                    disp('3. m_2')
                    disp('4. m_3')
                    disp('5. r')
                    disp('6. T_max')
                    disp('7. k')
                    disp('8. N')
                    disp('9. T_0')
                    disp('10. T_i0')
                    disp('11. V_0')
                    disp('12. B')
                    var5=input('Type 1 - 12: ');
                    if(var5==1)
                        disp('        ')
                        s2=input('Enter a second s value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labnine(s2,m1,m2,m3,r,Tmax,k,N,T0,Ti0,V0,B,time);
                        flag5=1;
                    elseif(var5==2)
                        disp('        ')
                        m12=input('Enter a second m_1 value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labnine(s,m12,m2,m3,r,Tmax,k,N,T0,Ti0,V0,B,time);
                        flag5=1;
                    elseif(var5==3)
                        disp('        ')
                        m22=input('Enter a second m_2 value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labnine(s,m1,m22,m3,r,Tmax,k,N,T0,Ti0,V0,B,time);
                        flag5=1;    
                    elseif(var5==4)
                        disp('        ')
                        m32=input('Enter a second m_3 value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labnine(s,m1,m2,m32,r,Tmax,k,N,T0,Ti0,V0,B,time);
                        flag5=1;    
                    elseif(var5==5)
                        disp('        ')
                        r2=input('Enter a second r value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labnine(s,m1,m2,m3,r2,Tmax,k,N,T0,Ti0,V0,B,time);
                        flag5=1;    
                    elseif(var5==6)
                        disp('        ')
                        Tmax2=input('Enter a second T_max value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labnine(s,m1,m2,m3,r,Tmax2,k,N,T0,Ti0,V0,B,time);
                        flag5=1;    
                    elseif(var5==7)
                        disp('        ')
                        k2=input('Enter a second k value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labnine(s,m1,m2,m3,r,Tmax,k2,N,T0,Ti0,V0,B,time);
                        flag5=1;    
                    elseif(var5==8)
                        disp('        ')
                        N2=input('Enter a second N value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labnine(s,m1,m2,m3,r,Tmax,k,N2,T0,Ti0,V0,B,time);
                        flag5=1;    
                    elseif(var5==9)
                        disp('        ')
                        T02=input('Enter a second T_0 value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labnine(s,m1,m2,m3,r,Tmax,k,N,T02,Ti0,V0,B,time);
                        flag5=1;    
                    elseif(var5==10)
                        disp('        ')
                        Ti02=input('Enter a second T_i0 value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labnine(s,m1,m2,m3,r,Tmax,k,N,T0,Ti02,V0,B,time);
                        flag5=1;    
                    elseif(var5==11)
                        disp('        ')
                        V02=input('Enter a second V_0 value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labnine(s,m1,m2,m3,r,Tmax,k,N,T0,Ti0,V02,B,time);
                        flag5=1;    
                    elseif(var5==12)
                        disp('        ')
                        B2=input('Enter a second B value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labnine(s,m1,m2,m3,r,Tmax,k,N,T0,Ti0,V0,B2,time);
                        flag5=1;    
                    else
                        disp('         ')
                        disp('Pardon?')
                        disp('           ')
                    end
                end
            
            elseif(var4==2)
                disp('            ')
                flag4=1;
                if(var3==1)
                    plot(y1(1,:),y1(2,:))
                    xlabel('Days')
                    ylabel('T')
                elseif(var3==2)
                    plot(y1(1,:),y1(3,:))
                    xlabel('Days')
                    ylabel('T_i')
                elseif(var3==3)
                    plot(y1(1,:),y1(4,:))
                    xlabel('Days')
                    ylabel('V')
                elseif(var3==4)
                    plot(y1(1,:),y1(5,:))
                    xlabel('Days')
                    ylabel('u^*')
                    axis([0 time -1 2])
                elseif(var3==5)
                    subplot(4,1,1);plot(y1(1,:),y1(2,:))
                    subplot(4,1,1);xlabel('Days')
                    subplot(4,1,1);ylabel('T')
                    subplot(4,1,2);plot(y1(1,:),y1(3,:))
                    subplot(4,1,2);xlabel('Days')
                    subplot(4,1,2);ylabel('T_i')
                    subplot(4,1,3);plot(y1(1,:),y1(4,:))
                    subplot(4,1,3);xlabel('Days')
                    subplot(4,1,3);ylabel('V')
                    subplot(4,1,4);plot(y1(1,:),y1(5,:))
                    subplot(4,1,4);xlabel('Days')
                    subplot(4,1,4);ylabel('u^*')
                    subplot(4,1,4);axis([0 time -1 2])
                end
                
            else
                disp('           ')
                disp('Pardon?')
                disp('            ')
            end
        end
        
    else 
        disp('     ')
        disp('Pardon?')
        disp('          ')
    end
end

if(var4==1)
    if(var3==1)
        plot(y1(1,:),y1(2,:),'b',y2(1,:),y2(2,:),'g')
        xlabel('Days')
        ylabel('T')
        legend('First value','Second value',0)
    elseif(var3==2)
        plot(y1(1,:),y1(3,:),'b',y2(1,:),y2(3,:),'g')
        xlabel('Days')
        ylabel('T_i')
        legend('First value','Second value',0)
    elseif(var3==3)
        plot(y1(1,:),y1(4,:),'b',y2(1,:),y2(4,:),'g')
        xlabel('Days')
        ylabel('V')
        legend('First value','Second value',0)
    elseif(var3==4)
        plot(y1(1,:),y1(5,:),'b',y2(1,:),y2(5,:),'g')
        xlabel('Days')
        ylabel('u^*')
        legend('First value','Second value',0)
        axis([0 time -1 2])
    elseif(var3==5)
        subplot(4,1,1);plot(y1(1,:),y1(2,:),'b',y2(1,:),y2(2,:),'g')
        subplot(4,1,1);xlabel('Days')
        subplot(4,1,1);ylabel('T')
        subplot(4,1,1);legend('First value','Second value',0)
        subplot(4,1,2);plot(y1(1,:),y1(3,:),'b',y2(1,:),y2(3,:),'g')
        subplot(4,1,2);xlabel('Days')
        subplot(4,1,2);ylabel('T_i')
        subplot(4,1,2);legend('First value','Second value',0)
        subplot(4,1,3);plot(y1(1,:),y1(4,:),'b',y2(1,:),y2(4,:),'g')
        subplot(4,1,3);xlabel('Days')
        subplot(4,1,3);ylabel('V')
        subplot(4,1,3);legend('First value','Second value',0)
        subplot(4,1,4);plot(y1(1,:),y1(5,:),'b',y2(1,:),y2(5,:),'g')
        subplot(4,1,4);xlabel('Days')
        subplot(4,1,4);ylabel('u^*')
        subplot(4,1,4);legend('First value','Second value',0)
        subplot(4,1,4);axis([0 time -1 2])
    end
end
