% Script to see if we are on the frontside or the backside of the power required curve.
%
% This script must be run after  PredatorMainProgram.m (AircraftMainProgram.m) because it assumes that
% the vehicle geometric constants like Cd_0, k, S_w and rho are defined.
%
Vknots=40:10:140;
Vfps=Vknots*1.688;
qbarS=.5*rho*Vfps.^2*S_w;
CLxx=W./qbarS;
CDxx=Cd_0+k*CLxx.^2;
DVxx=qbarS.*CDxx.*Vfps;
figure(4)
plot(Vknots,DVxx)
xlabel('V(knots)')
ylabel('Power Req (ft-lbf/s)')
hold on
%YI = INTERP1(X,Y,XI)
DVi=interp1(Vknots,DVxx,U);
plot(U,DVi,'x')
text(U,DVi+2000,'Trim point')
text(100,25000,'Frontside')
text(45,25000,'Backside')
title('Power Required Curve')
hold off