function rho = density(h) % This is the density calculator based on height. It is based on the US % Standard Atmosphere of 1976. % Source: http://scipp.ucsc.edu/outreach/BALLOON/Atmosphere/1976%20Standard%20Atmosphere.htm % % VARIABLES and UNITS % % conventions: Large arrays are in all caps % Vectors and other variables are in mixed case, as appropriate % % h :The height above sea level, in m. % rho :Density of the atmosphere, in kg/m3. % rho_o :Density of the atmosphere at sea level, in kg/m3. global data; global index; % CONSTANTS rho_o = data(1,92); % kg/m3 % MAIN PROGRAM if (h <= 11000) rho = rho_o * (1 - h/44329)^(4.255876); elseif (h <= 20000) rho = rho_o * (0.297076)*exp((10999-h)/6341.4); elseif h <= 32000 rho = rho_o * (0.978261 + h/201010)^(-35.16319); elseif h <= 47000 rho = rho_o * (0.857003 + h/57944)^(-13.20114); elseif h <= 51000 rho = rho_o * (0.00116533)*exp((46998-h)/7922); elseif h <= 71000 rho = rho_o * (0.79899 - h/184800)^11.20114; else rho = rho_o * (0.79899 - h/184800)^11.20114; % same as <=71000 end data(index,92) = rho;