% 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.4058;
       m10 =      -1.566;
       m01 =       3.293;
       m20 =       1.398;
       m11 =       8.309;
       m02 =      -8.536;
       m30 =      -0.477;
       m21 =      -6.092;
       m12 =         -10;
       m03 =       12.94;
       m40 =     -0.2242;
       m31 =       2.752;
       m22 =       3.532;
       m13 =       6.017;
       m04 =      -8.973;
       m50 =      0.1168;
       m41 =     -0.3159;
       m32 =      -1.062;
       m23 =     -0.4478;
       m14 =      -1.592;
       m05 =       2.383;

       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.6036;
       p10 =      -0.141;
       p01 =    -0.02322;
       p20 =  9.901e-008;
       p11 =       1.198;
       p02 =       0.143;
       p30 = -1.964e-008;
       p21 = -8.301e-008;
       p12 =      -0.446;
       p03 =     -0.0291;

                
       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.4982;
       e10 =      0.6748;
       e01 =       2.962;
       e20 =      -3.954;
       e11 =     -0.2306;
       e02 =      -7.573;
       e30 =       6.987;
       e21 =       1.036;
       e12 =       1.308;
       e03 =       9.335;
       e40 =      -5.239;
       e31 =      -2.152;
       e22 =     0.08375;
       e13 =      -1.361;
       e04 =       -5.65;
       e50 =       1.367;
       e41 =       1.318;
       e32 =     -0.4633;
       e23 =      0.3655;
       e14 =      0.2962;
       e05 =       1.358;

      
     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

