function T = temperature(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 % % This function is at least in the SECOND ORDER phase of development. % 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. % T :Temperature of the atmosphere, in K. % T_o :Temperature of the atmosphere at sea level, in K. global data; global index; % CONSTANTS T_o = data(1,90); % K % MAIN PROGRAM if (h <= 11000) T = T_o * (1 - h / 44329); elseif (h <= 20000) T = T_o * 0.751865; elseif h <= 32000 T = T_o * (0.682457 + h/288136); elseif h <= 47000 T = T_o * (0.482561 + h/102906); elseif h <= 51000 T = T_o * (0.939268); elseif h <= 71000 T = T_o * (1.434843 - h/102906); else % this line is what is making this a SECOND and not THIRD ORDER simulation T = T_o * (1.434843 - h/102906); % same as <=71000 end data(index,90) = T;