% Delivered to the Government in Accordance with Contract FA8650-10-C-7080
% 
%  (c) 2011 United Technologies Corp.
% Developed with the sponsorship of the Defense Advanced Research Projects Agency (DARPA).
%  
% Permission is hereby granted, free of charge, to any person obtaining a copy of this data, including any software or models in source or binary form, as well as any drawings, specifications, and documentation (collectively "the Data"), to deal in the Data without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Data, and to permit persons to whom the Data is furnished to do so, subject to the following conditions:
%  
% The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Data.
%  
% THE DATA IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, SPONSORS, DEVELOPERS, CONTRIBUTORS, OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE DATA OR THE USE OR OTHER DEALINGS IN THE DATA.
% 

% This script edits data so that it can be used in the surface fitting tool
h = 0;

beta = linspace(0, 1, 61);
speed = linspace(0.8, 1.1, 61);

for count1 = 1:61
Mass_nd = 0;
PR_nd = 0;
Efficiency_nd = 0;
Speed = speed(count1);
for count2 = 1:61
    
Beta = beta(count2);

       m00 =      0.6442;
       m10 =      -3.133;
       m01 =       -3.42;
       m20 =       3.732;
       m11 =       12.48;
       m02 =       8.979;
       m30 =     -0.1131;
       m21 =      -14.56;
       m12 =      -13.19;
       m03 =      -8.955;
       m40 =      -2.043;
       m31 =       6.893;
       m22 =       9.736;
       m13 =       6.009;
       m04 =       4.494;
       m50 =      0.7387;
       m41 =     -0.5112;
       m32 =      -3.185;
       m23 =      -1.531;
       m14 =      -1.144;
       m05 =     -0.9091;


       Mass_nd(count2) = (m00 + m10*Beta + m01*Speed + m20*Beta^2 + m11*Beta*Speed + m02*Speed^2 + m30*Beta^3 + m21*Beta^2*Speed ... 
                    + m12*Beta*Speed^2 + m03*Speed^3 + m40*Beta^4 + m31*Beta^3*Speed + m22*Beta^2*Speed^2 ...
                    + m13*Beta*Speed^3 + m04*Speed^4 + m50*Beta^5 + m41*Beta^4*Speed + m32*Beta^3*Speed^2 ...
                    + m23*Beta^2*Speed^3 + m14*Beta*Speed^4 + m05*Speed^5)/Speed;

       p00 =      0.7189;
       p10 =      -1.955;
       p01 =       -1.09;
       p20 =  -2.14e-008;
       p11 =        5.28;
       p02 =       1.415;
       p30 =  9.879e-009;
       p21 =  4.031e-009;
       p12 =      -2.487;
       p03 =     -0.4697;

       PR_nd(count2) = p00 + p10*Beta + p01*Speed + p20*Beta^2 + p11*Beta*Speed + p02*Speed^2 + p30*Beta^3 + p21*Beta^2*Speed ... 
                    + p12*Beta*Speed^2 + p03*Speed^3;
                    
       e00 =     0.07005;
       e10 =       2.996;
       e01 =       5.236;
       e20 =      -4.713;
       e11 =      -9.025;
       e02 =      -12.54;
       e30 =       5.073;
       e21 =        7.08;
       e12 =        10.3;
       e03 =       15.27;
       e40 =      -5.084;
       e31 =       1.908;
       e22 =      -9.926;
       e13 =      -2.857;
       e04 =      -9.418;
       e50 =       1.768;
       e41 =     -0.3541;
       e32 =     -0.5155;
       e23 =       3.813;
       e14 =     -0.4358;
       e05 =       2.302;
      
     Efficiency_nd(count2) = e00 + e10*Beta + e01*Speed + e20*Beta^2 + e11*Beta*Speed + e02*Speed^2 + e30*Beta^3 + e21*Beta^2*Speed ... 
                    + e12*Beta*Speed^2 + e03*Speed^3 + e40*Beta^4 + e31*Beta^3*Speed + e22*Beta^2*Speed^2 ...
                    + e13*Beta*Speed^3 + e04*Speed^4 + e50*Beta^5 + e41*Beta^4*Speed + e32*Beta^3*Speed^2 ...
                    + e23*Beta^2*Speed^3 + e14*Beta*Speed^4 + e05*Speed^5;
end


if abs(Speed- 1) < 0.001
hold on
plot(Mass_nd, PR_nd,'b');

elseif abs(Speed - 1.1)< 0.001 
plot(Mass_nd, PR_nd,'r');
hold on

else
    
plot(Mass_nd, PR_nd,'k');
hold on
end

end

