% Check_Constants2.m     Version 9.0 10/30/07
%
% OBJECTIVE: Perform a BELIEVABILITY CHECK of the array called constant
% supplied by each of 4 teams
% INPUTS: The array called constant.
% OUTPUTS: Text in the Matlab command window.
%
clear all
% constant1=101:167;
% constant2=201:267;
% constant3=301:367;
% constant4=401:467;

disp(' '); disp(' Start Check_Constants2 here <<<<<<<<<<<<<<<<<')
Constant_Combined



disp(' '); disp(' ')
disp(' '); disp('BELIEVABILITY CHECK of the array called constant');
string1=['For AAE451 Fall 2007'];
disp(string1); disp(' ')
xx=1:67;
NameScript; % Get constant names and comments.
for i=1:67
	string1=['constant(',num2str(xx(i)),')= ',num2str(constant1(i)),', ',num2str(constant2(i)),', ',num2str(constant3(i)),', ',num2str(constant4(i))];
	disp(string1)
	string2=['disp(name',num2str(i),')'];
	eval(string2)
	if eval(['isempty(comment',num2str(i),')'])
	else
		string3=['disp(comment',num2str(i),')'];
		eval(string3)
    end



    if i==56

        for j=1:4
            string10=['constant(46)=constant',num2str(j),'(46);'];
            string11=['constant(29)=constant',num2str(j),'(29);'];
            string12=['constant(56)=constant',num2str(j),'(56);'];
            string13=['constant(57)=constant',num2str(j),'(57);'];
            eval(string10)
            eval(string11)
            eval(string12)
            eval(string13)


            string14=['disp(''Team ',num2str(j),''')']; eval(string14)
            StaticMargin=-constant(46)/constant(29);
            Xbarref=constant(56);
            stringA=['Arbitrary Ref. Point,       Xbarref= ',num2str(Xbarref),' (fraction of chord)'];
            stringC=['Static Margin     (Xbarac-Xbarref) = ',num2str(StaticMargin),' (fraction of chord)'];
            disp(stringA); disp(stringC); 
            string4=['Typically 0.05 to 0.50 of the reference chord.'];
            disp(string4)
            disp('NOTE: static margin above is relative the the arbitrary ref point, NOT the c.g.')
            disp(' ')
        end
    end
    if i==57
        for j=1:4
            string10=['constant(46)=constant',num2str(j),'(46);'];
            string11=['constant(29)=constant',num2str(j),'(29);'];
            string12=['constant(56)=constant',num2str(j),'(56);'];
            string13=['constant(57)=constant',num2str(j),'(57);'];
            eval(string10)
            eval(string11)
            eval(string12)
            eval(string13)

            % Compute static margin in fraction of MAC.
            string14=['disp(''Team ',num2str(j),''')']; eval(string14)
            Xbarcg=constant(57); 
            Xbarref=constant(56);
            Cm_alpha=constant(46);
            CL_alpha=constant(29);
            Xbarac=-Cm_alpha/CL_alpha+Xbarref;
            StaticMargin=Xbarac-Xbarcg;
            stringA=['C.G. location,               Xbarcg= ',num2str(Xbarcg),' (fraction of chord)'];
            stringB=['Aerodynamic center location, Xbarac= ',num2str(Xbarac),' (fraction of chord)'];
            stringC=['Static Margin      (Xbarac-Xbarcg) = ',num2str(StaticMargin),' (fraction of chord)'];
            disp(stringA); disp(stringB); disp(stringC); 
            string4=['Typically 0.05 to 0.50 of the reference chord.'];
            disp(string4)
            disp('NOTE: static margin above is relative the the c.g. This is the static margin that will be reflected in the subsequent simulations')
            disp(' ')
        end
    end
 



    disp(' ')
end
