function ShockProp(xi,prop1,prop2)
% ======================================================
%
% The program interpolates Normal Shock Properties from a given table of
% properties.
% Table found at: http://utwired.engr.utexas.edu/che354/normal_shock.pdf
% Modified to match values from textbook Fundamentals of Aerodynamics by
% John D. Anderson (2005)
%
% Input parameters explained:
% xi: The known parameter, related to property prop1. Can be a single
% integer or a 1-dimensional matrix
% prop1: The known property, related to xi
% prop2: The unknown quantity searched for, related to output desired
%
% Properties valid for prop1 and prop2
% prop* | Book Name | Description
% -------------------------------------------------------------
% M | M1 | Incoming Mach
% sprat | p2/p1 | Static Pressure Ratio
% denrat | ?2/?1 | Density Ratio
% Trat | T2/T1 | Temperature Ratio
% tprat | p02/p01 | Total Pressure Ratio
% tsprat | p02/p1 | Total to Static Pressure Ratio
% M2 | M2 | Outgoing Mach
%
%
% Examples of the program in use:
%
% Written by Jared Miller for Professor Kevin Cole
% Last modified: August 14, 2009
%
% ======================================================
%Loads the shock table
load shockdata.mat data
%Check to see which properties are being asked for and then picks the right
%range for x and y.
if strcmp(prop1,'M')==1
x=data(:,1);
elseif strcmp(prop1,'M2')==1
x=data(:,2);
elseif strcmp(prop1,'sprat')==1
x=data(:,3);
elseif strcmp(prop1,'denrat')==1
x=data(:,4);
elseif strcmp(prop1,'Trat')==1
x=data(:,5);
elseif strcmp(prop1,'tprat')==1
x=data(:,6);
elseif strcmp(prop1,'tsprat')==1
x=data(:,7);
else
error('Prop1 not specified correctly. Valid entries: M,M2,sprat,denrat,Trat,tprat,tsprat (case sensitive)')
end
if strcmp(prop2,'M')==1
y=data(:,1);
elseif strcmp(prop2,'M2')==1
y=data(:,2);
elseif strcmp(prop2,'sprat')==1
y=data(:,3);
elseif strcmp(prop2,'denrat')==1
y=data(:,4);
elseif strcmp(prop2,'Trat')==1
y=data(:,5);
elseif strcmp(prop2,'tprat')==1
y=data(:,6);
elseif strcmp(prop2,'tsprat')==1
y=data(:,7);
else
error('Prop2 not specified correctly. Valid entries: M,M2,sprat,denrat,Trat,tprat,tsprat (case sensitive)')
end
%checks to see that xi lies within the valid range of x
xmax=max(x);
xmin=min(x);
ximax=max(xi);
ximin=min(xi);
if ximax>xmax
str = num2str(xmax);
str2 = num2str(ximax);
error([prop1,' value (',str2,') is too large. Maximum ',prop1,' value is ',str])
elseif ximin<xmin
str = num2str(xmin);
str2 = num2str(ximin);
error([prop1,' value (',str2,') is too small. Minimum ',prop1,' value is ',str])
end
%Interpolates using built-in MATALB interpolate function, interp1
IdealAir=interp1(x,y,xi);
%displays on screen (optional step)
disp([prop2,' = ',num2str(IdealAir)]);