close

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

r = input('Enter a value for r (tumor growth rate): ');
disp('         ')
a = input('Enter a value for the first weight parameter a: ');
disp('          ')
b = input('Enter a value for the second weight parameter b: ');
disp('           ')
d = input('Enter a value for delta (dose magnitude): ');
disp('           ')
while(flag1==0)
    var1 = input('Enter a value for N_d (desired tumor density): ');
    if((0<=var1)&(1>=var1));
            nd=var1;
            flag1=1;
    else
        disp('            ')
        disp('ERROR: N_d must be between 0 and 1.')
        disp('            ')
    end
end
disp('           ')
while(flag2==0)
    var2 = input('Enter a value for N_0 (initial tumor density): ');
    if((0<=var2)&(1>=var2))
        n0=var2;
        flag2=1;
    else
        disp('                ')
        disp('ERROR: N_0 must be between 0 and 1.');
        disp('                ')
    end
end
disp('           ')
days = input('Enter the number of days you would like to run this simulation: ');
disp('            ')
disp('One moment please...')
y1=labfive(r,a,b,d,nd,n0,days);

disp('               ')

while(flag3==0)
    disp('Would you like to plot')
    disp('   1. Tumor density (state)')
    disp('   2. Pharmacokinetics of the drug (control)')
    disp('   3. both')
    var3=input('Type 1, 2, or 3: ');

    if((var3==1) | (var3==2) | (var3==3))
        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. r')
                    disp('2. a')
                    disp('3. b')
                    disp('4. delta')
                    disp('5. N_d')
                    disp('6. N_0')
                    var5=input('Type 1, 2, 3, 4, 5, or 6: ');
                    if(var5==1)
                        disp('        ')
                        r2=input('Enter a second r value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labfive(r2,a,b,d,nd,n0,days);
                        flag5=1;
                    elseif(var5==2)
                        disp('        ')
                        a2=input('Enter a second a value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labfive(r,a2,b,d,nd,n0,days);
                        flag5=1;
                    elseif(var5==3)
                        disp('        ')
                        b2=input('Enter a second b value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labfive(r,a,b2,d,nd,n0,days);
                        flag5=1; 
                    elseif(var5==4)
                        disp('        ')
                        d2=input('Enter a second delta value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labfive(r,a,b,d2,nd,n0,days);
                        flag5=1;
                    elseif(var5==5)
                        disp('        ')
                        nd2=input('Enter a second N_d value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labfive(r,a,b,d,nd2,n0,days);
                        flag5=1;
                    elseif(var5==6)
                        disp('        ')
                        n02=input('Enter a second N_0 value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labfive(r,a,b,d,nd,n02,days);
                        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('Tumor Density')
                    axis([0 days 0 1])
                elseif(var3==2)
                    plot(y1(1,:),y1(3,:))
                    xlabel('Days')
                    ylabel('Pharmacokinetics')
                elseif(var3==3)
                    subplot(2,1,1);plot(y1(1,:),y1(2,:))
                    subplot(2,1,1);xlabel('Days')
                    subplot(2,1,1);ylabel('Tumor Density')
                    subplot(2,1,1);axis([0 days 0 1])
                    subplot(2,1,2);plot(y1(1,:),y1(3,:))
                    subplot(2,1,2);xlabel('Days')
                    subplot(2,1,2);ylabel('Pharmacokinetics')
                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('Tumor Density')
        axis([0 days 0 1])
        legend('First value','Second value',0)
    elseif(var3==2)
        plot(y1(1,:),y1(3,:),'b',y2(1,:),y2(3,:),'g')
        xlabel('Days')
        ylabel('Pharmacokinetics')
        legend('First value','Second value',0)
    elseif(var3==3)
        subplot(2,1,1);plot(y1(1,:),y1(2,:),'b',y2(1,:),y2(2,:),'g')
        subplot(2,1,1);xlabel('Days')
        subplot(2,1,1);ylabel('Tumor Density')
        subplot(2,1,1);axis([0 days 0 1])
        subplot(2,1,1);legend('First value','Second value',0)
        subplot(2,1,2);plot(y1(1,:),y1(3,:),'b',y2(1,:),y2(3,:),'g')
        subplot(2,1,2);xlabel('Days')
        subplot(2,1,2);ylabel('Pharmacokinetics')
        subplot(2,1,2);legend('First value','Second value',0)
    end
end
