%ascorrea


function dragpolar
count=1;
for answer=[1 2]
    for answer2=[1 2 3]
% answer=input('Input Aviator (1), Sleak (2):');
% answer2=input('Take-off (1), Cruise (2), Landing (3):');

cd0Aviator=.01866;
cd0Sleak=.02056;
alphadeg=[-12:2:12];
alpha=(pi/180)*(alphadeg);
if answer==1
    if answer2==1;
        for i=1:length(alpha)
        CL(i)=5.221144*(alpha(i))+.2581;
        Cd(i)=cd0Aviator+CL(i)^2/(.8*pi()*10);
        end
        graphname='Drag Polar, Aviator, Take-off';
    end


elseif answer==2
        if answer2==1;
        for i=1:length(alpha)
        CL(i)=3.522567397*(alpha(i))+.4088;
        CLcanard(i)=(4.122266*(alpha(i))+.4891)*(379.28/1496);
        Cd(i)=cd0Sleak+CL(i)^2/(.8*pi()*7.9)+CLcanard(i)^2/(.8*pi()*7.831);
        end
        graphname='Drag Polar, Sleak, Take-Off';
    end
    
    if answer2==2;
        for i=1:length(alpha)
        CL(i)=2.887819338*(alpha(i))+.4007;
%         Cd(i)=cd0Sleak+CL(i)^2/(.8*pi()*10);
        CLcanard(i)=(3.819627*(alpha(i))+.4886)*(379.28/1496);
        Cd(i)=cd0Sleak+CL(i)^2/(.8*pi()*7.9)+CLcanard(i)^2/(.8*pi()*7.831);
        end
        graphname='Drag Polar, Sleak, Cruise';
    end
    
     if answer2==3;
        for i=1:length(alpha)
        CL(i)=3.499816553*(alpha(i))+.3987;
%         Cd(i)=cd0Sleak+CL(i)^2/(.8*pi()*10);
        CLcanard(i)=(4.12721*(alpha(i))+.4891)*(379.28/1496);
        Cd(i)=cd0Sleak+CL(i)^2/(.8*pi()*7.9)+CLcanard(i)^2/(.8*pi()*7.831);
        end
        graphname='Drag Polar, Sleak, landing';
    end
else
    error('Invalid Choice')
end
hold on
figure(count)
hold on
axisX0=linspace(0,max(cd));
axisY0=zeros(1,length(axisX0));
figure(count)
hold on
plot(axisX0, axisY0,'k--');
figure(count)
hold on
plot(Cd, CL);
figure(count)
hold on
plot(Cd, CL, '.');
title(graphname);
xlabel('C_d');
ylabel('C_L');
axis([0, .08, -1, 1.5]);
for i=1:length(alphadeg)
    alphalabel=num2str(alphadeg(i));
    label=['  \alpha =' alphalabel];
text(Cd(i), CL(i), label)
end
count=count+1;
    end
end
end