% Alpha trim maps
load data
clf
v=data(:,1);
hdot=data(:,2);
alpha=data(:,3);
Bhp=data(:,4);
cost=data(:,5);
gamma=asin(hdot./v);
ifig=0;


% hdot versus alpha
symb=['mo-';'cx-';'r+-';'g*-';'bs-';'md-';'cv-';'r^-';'g<-';'b>-';'ms-';'r+-'];
ifig=ifig+1;
figure(ifig)
clf
%plot(alpha*57.3,hdot,'+')
title([title_string,', Trim vertical velocity (hdot) versus trim angle of attack (alpha)'])
xlabel('alpha (deg)')
ylabel('hdot (ft/sec)')
axis;
hold on
for i=0:10
	for j=1:11; a(j)=alpha(i*11+j); h(j)=hdot(i*11+j); end
	plot(a*57.3,h,symb(i+1,:))
end
hold off
str1=['Bhp=', num2str(Bhp(1))];           str2=['Bhp=',num2str(Bhp(1*N_alpha+1))]; str3=['Bhp=',num2str(Bhp(2*N_alpha+1))];
str4=['Bhp=', num2str(Bhp(3*N_alpha+1))]; str5=['Bhp=',num2str(Bhp(4*N_alpha+1))]; str6=['Bhp=',num2str(Bhp(5*N_alpha+1))];
str7=['Bhp=', num2str(Bhp(6*N_alpha+1))]; str8=['Bhp=',num2str(Bhp(7*N_alpha+1))]; str9=['Bhp=',num2str(Bhp(8*N_alpha+1))];
str10=['Bhp=',num2str(Bhp(9*N_alpha+1))]; str11=['Bhp=',num2str(Bhp(10*11+1))]; 
legend(str1,str2,str3,str4,str5,str6,str7,str8,str9,str10,str11,-1)
text2(.3,.9,'Use Bhp to control hdot.')
text2(.3,.85,'Increase Bhp to increase hdot.')
text2(.3,.8,'This works on the frontside and on the backside.')
text2(.5,.35,'Slope is zero or negative (counterintuitive).')
text2(.5,.25,'Alpha has litle or no effect ')
text2(.5,.2,'on hdot on the backside of the') 
text2(.5,.15,'power required curve.')
text2(.15,.15,'Alpha has some effect ') 
text2(.15,.10,'on the frontside.')
text2(.05,.05,'The slope is intuitive.')

% gamma versus alpha
ifig=ifig+1;
figure(ifig)
clf
title([title_string,', Trim flight path angle (gamma) versus trim alpha'])
xlabel('alpha (deg)')
ylabel('gamma (deg)')
axis;
hold on
for i=0:10
	for j=1:11; a(j)=alpha(i*11+j); h(j)=57.5*gamma(i*11+j); end
	plot(a*57.3,h,symb(i+1,:))
end
hold off
legend(str1,str2,str3,str4,str5,str6,str7,str8,str9,str10,str11,-1)
text2(.2,.9,'Bhp has a strong effect on gamma on')
text2(.2,.85,'BOTH the frontside and the backside')
text2(.2,.8,'of the power required curve.')
text2(.3,.75,'Add power to go up.')
text2(.5,.1,'Alpha has small or counter-intuitive') 
text2(.5,.05,'effect on gamma on the backside.')
text2(.05,.10,'Alpha has intuitive effect')
text2(.05,.05,'on gamma on the frontside.')



% speed v versus alpha
ifig=ifig+1;
figure(ifig)
clf
%plot(alpha*57.3,v,'+')
title([title_string,', Trim angle of attack (alpha) vs trim speed'])
xlabel('alpha (deg)')
ylabel('speed (ft/sec)')
axis;

hold on
for i=0:10
	for j=1:11; a(j)=alpha(i*11+j); vv(j)=v(i*11+j); end
	plot(a*57.3,vv,symb(i+1,:))
end
hold off
legend(str1,str2,str3,str4,str5,str6,str7,str8,str9,str10,str11,-1)
text2(.2,.9,'Alpha has a strong and intuitive effect')
text2(.2,.85,'on speed on BOTH the frontside and the')
text2(.2,.8,'backside of the power required curve.')
text2(.2,.75,'Pull up (increase alpha) to slow down (like a roller coaster).')
text2(.1,.6,'Bhp has little effect on')
text2(.1,.55,'speed on the frontside.')
text2(.5,.10,'Bhp has a counter-intuitive effect on')
text2(.5,.05,'speed on the backside.')



%gamma versus speed
ifig=ifig+1;
figure(ifig)
clf
title([title_string,', Trim flight path angle (gamma) vs trim speed'])
ylabel('gamma (deg)')
xlabel('speed (ft/sec)')
axis;

hold on
for i=0:10
	for j=1:11; a(j)=gamma(i*11+j); vv(j)=v(i*11+j); end
	plot(vv,a*57.3,symb(i+1,:))
end
hold off
legend(str1,str2,str3,str4,str5,str6,str7,str8,str9,str10,str11,-1)
text2(.2,.9,'The slope of this line at low speed')
text2(.2,.85,'is limited by the military specifications')
text2(.1,.1,'The slope at low speed')
text2(.1,.05,'cannot be too positive.')



ifig=ifig+1;
figure(ifig)
V=v(1:N_alpha);
Cl_trim=2*weight./(rho*V.*V*s);
Cd_trim=cd0+k*Cl_trim.*Cl_trim;
Drag=.5*rho*V.*V*s.*Cd_trim;
PowerReq=Drag.*V;
plot(V,PowerReq)
title([title_string,', Power Required Curve (for level flight)'])
ylabel('Power Req (ft-lbf/sec)')
xlabel('speed (ft/sec)')
text2(.25,.15,'Frontside')
text2(.05,.15,'Backside')
text2(.2,.02,'min')
text2(.8,.8,'Frontside')
