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 d: ');
    if(var1>=0)
        d = var1;
        flag1=1;
    else
        disp('        ')
        disp('ERROR: d must be positive')
        disp('         ')
    end
end
flag1=0;
disp('         ')
while(flag1==0)    
    var1 = input('Enter a value for 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 a value for c: ');
    if(var1>=0)
        c = var1;
        flag1=1;
    else
        disp('        ')
        disp('ERROR: c must be positive')
        disp('         ')
    end
end
flag1=0;
disp('           ')
while(flag1==0)    
    var1 = input('Enter a value for e: ');
    if(var1>=0)
        e = var1;
        flag1=1;
    else
        disp('        ')
        disp('ERROR: e must be positive')
        disp('         ')
    end
end
flag1=0;
disp('              ')
while(flag1==0)    
    var1 = input('Enter a value for g: ');
    if(var1>=0)
        g = var1;
        flag1=1;
    else
        disp('        ')
        disp('ERROR: g must be positive')
        disp('         ')
    end
end
flag1=0;
disp('         ')
while(flag1==0)
    while(flag2==0)
        var2 = input('Enter an initial susceptible percentage (x_10): ');
        if((var2>=0)&(var2<=1))
            x10 = var2;
            flag2=1;
        else
            disp('        ')
            disp('ERROR: x_10 must be between 0 and 1')
            disp('        ')
        end
    end
    flag2=0;
    disp('          ')
    while(flag2==0)
        var2 = input('Enter an initial exposed percentage (x_20): ');
        if((var2>=0)&(var2<=1))
            x20 = var2;
            flag2=1;
        else
            disp('        ')
            disp('ERROR: x_20 must be between 0 and 1')
            disp('        ')
        end
    end
    flag2=0;
    disp('          ')
    while(flag2==0)
        var2 = input('Enter an initial infectious percentage (x_30): ');
        if((var2>=0)&(var2<=1))
            x30 = var2;
            flag2=1;
        else
            disp('        ')
            disp('ERROR: x_30 must be between 0 and 1')
            disp('        ')
        end
    end
    if(x10+x20+x30<=1)
        flag1=1;
    else
        disp('      ')
        disp('ERROR: x_10 + x_20 + x_30 must be less than or equal to 1.')
        disp('         ')
        flag2=0;
    end
end
flag2=0;
disp('        ')
while(flag2==0)
    var2 = input('Enter a value for the weight parameter W: ');
    if(var2>0)
        W = var2;
        flag2=1;
    else
        disp('        ')
        disp('ERROR: W must be positive')
        disp('        ')
    end
end
flag2=0;
disp('          ')
while(flag2==0)
    var2 = input('How long would you like to run this system: ');
    if(var2>0)
        T=var2;
        flag2=1;
    else
        disp('        ')
        disp('ERROR: T must be positive.')
        disp('         ')
    end
end
disp('              ')
disp('One moment please...')
y1=labeight(d,b,c,e,g,x10,x20,x30,W,T);

disp('               ')

while(flag3==0)
    disp('Would you like to plot')
    disp('   1. Susceptible')
    disp('   2. Exposed')
    disp('   3. Infectious')
    disp('   4. Vaccination Rate (control)')
    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. d')
                    disp('2. b')
                    disp('3. c')
                    disp('4. e')
                    disp('5. g')
                    disp('6. x_10')
                    disp('7. x_20')
                    disp('8. x_30')
                    disp('9. W')
                    var5=input('Type 1, 2, 3, 4, 5, 6, 7, 8, or 9: ');
                    if(var5==1)
                        disp('        ')
                        d2=input('Enter a second d value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labeight(d2,b,c,e,g,x10,x20,x30,W,T);
                        flag5=1;
                    elseif(var5==2)
                        disp('        ')
                        b2=input('Enter a second b value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labeight(a,b2,c,e,g,x10,x20,x30,W,T);
                        flag5=1;   
                    elseif(var5==3)
                        disp('        ')
                        c2=input('Enter a second c value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labeight(a,b,c2,e,g,x10,x20,x30,W,T);
                        flag5=1;   
                    elseif(var5==4)
                        disp('        ')
                        e2=input('Enter a second e value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labeight(a,b,c,e2,g,x10,x20,x30,W,T);
                        flag5=1;   
                    elseif(var5==5)
                        disp('        ')
                        g2=input('Enter a second g value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labeight(a,b,c,e,g2,x10,x20,x30,W,T);
                        flag5=1;   
                    elseif(var5==6)
                        disp('        ')
                        x102=input('Enter a second x_10 value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labeight(a,b,c,e,g,x102,x20,x30,W,T);
                        flag5=1;   
                    elseif(var5==7)
                        disp('        ')
                        x202=input('Enter a second x_20 value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labeight(a,b,c,e,g,x10,x202,x30,W,T);
                        flag5=1;  
                    elseif(var5==8)
                        disp('        ')
                        x302=input('Enter a second x_30 value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labeight(a,b,c,e,g,x10,x20,x302,W,T);
                        flag5=1;   
                    elseif(var5==9)
                        disp('        ')
                        W2=input('Enter a second W value: ');
                        disp('            ')
                        disp('One moment please...')
                        y2=labeight(a,b,c,e,g,x10,x20,x30,W2,T);
                        flag5=1;      
                    else
                        disp('         ')
                        disp('Pardon?')
                        disp('           ')
                    end
                end
            
            elseif(var4==2)
                disp('            ')
                flag4=1;
                if(var3==1)
                    plot(y1(1,:),y1(2,:))
                    xlabel('Time')
                    ylabel('Susceptible')
                elseif(var3==2)
                    plot(y1(1,:),y1(3,:))
                    xlabel('Time')
                    ylabel('Exposed')
                elseif(var3==3)
                    plot(y1(1,:),y1(4,:))
                    xlabel('Time')
                    ylabel('Infectious')
                elseif(var3==4)
                    plot(y1(1,:),y1(5,:))
                    xlabel('Time')
                    ylabel('Vaccination Rate')    
                elseif(var3==5)
                    subplot(4,1,1);plot(y1(1,:),y1(2,:))
                    subplot(4,1,1);xlabel('Time')
                    subplot(4,1,1);ylabel('Susceptible')
                    subplot(4,1,2);plot(y1(1,:),y1(3,:))
                    subplot(4,1,2);xlabel('Time')
                    subplot(4,1,2);ylabel('Exposed')
                    subplot(4,1,3);plot(y1(1,:),y1(4,:))
                    subplot(4,1,3);xlabel('Time')
                    subplot(4,1,3);ylabel('Infectious')
                    subplot(4,1,4);plot(y1(1,:),y1(5,:))
                    subplot(4,1,4);xlabel('Time')
                    subplot(4,1,4);ylabel('Vaccination Rate')
                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('Time')
        ylabel('Susceptible')
        legend('First value','Second value',0)
    elseif(var3==2)
        plot(y1(1,:),y1(3,:),'b',y2(1,:),y2(3,:),'g')
        xlabel('Time')
        ylabel('Exposed')
        legend('First value','Second value',0)
    elseif(var3==3)
        plot(y1(1,:),y1(4,:),'b',y2(1,:),y2(4,:),'g')
        xlabel('Time')
        ylabel('Infectious')
        legend('First value','Second value',0)
    elseif(var3==4)
        plot(y1(1,:),y1(5,:),'b',y2(1,:),y2(5,:),'g')
        xlabel('Time')
        ylabel('Vaccination Rate')
        legend('First value','Second value',0)    
    elseif(var3==5)
        subplot(4,1,1);plot(y1(1,:),y1(2,:),'b',y2(1,:),y2(2,:),'g')
        subplot(4,1,1);xlabel('Time')
        subplot(4,1,1);ylabel('Susceptible')
        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('Time')
        subplot(4,1,2);ylabel('Exposed')
        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('Time')
        subplot(4,1,3);ylabel('Infectious')
        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('Time')
        subplot(4,1,4);ylabel('Vaccination Rate')
        subplot(4,1,4);legend('First value','Second value',0)
    end
end
