Code:

%Goal: Calculate Pressure, Pressure Ratio, Density, Density Ratio,
%Temperature, and Temperature Ratio based on an Altitude input.
%This program operates using air as a medium. The Gas Constant, density,
%and atmospheric pressure are constant and refer to standard atmospheric temperature
%and pressure. Gravitational pull is also considered constant.
clear,clc
alt=input('Enter your altitude: ');
go=9.8; %m/s^2
R=287.05; %J/K mol
P1=101325; %N/,^2
rho1=1.225; %kg/m^3
T1=288.16; %K
h1=0;
a=[-6.5*10^-3 3*10^-3 -4.5*10^-3 4*10^3];
aeng=a.*.54864;
i=1;
while i<=length(alt)
if alt==0
T(i)=288.6 %K
Prat(i)=1
rhorat(i)=1
elseif alt>=0 & alt<11000
a=a(1); %K/m
T(i)=T1+a.*(alt(i)-h1)
Prat(i)=(T(i)./T1).^-(go./(a.*R))
rhorat(i)=exp(1).^-(go./(a.*T(i))+1)
elseif alt>=11000 & alt<25000
T(i)=216.66 %K
Prat(i)=exp(1).^-(go./(R.*T(i)).*(alt(i)-h1))
rhorat(i)=exp(1).^-(go./(R.*T(i)).*(alt(i)-h1))
elseif alt>=25000 & alt<47000
a=a(2); %K/m
T(i)=T1+a.*(alt(i)-h1)
Prat(i)=(T(i)./T1).^-(go./(a.*R))
rhorat(i)=exp(1).^-(go./(a.*T(i))+1)
elseif alt>=47000 &alt<53000
T(i)=282.66 %K
Prat(i)=exp(1).^-(go./(R.*T(i)).*(alt(i)-h1))
rhorat(i)=Prat(i+1)
elseif alt>=53000 & alt<79000
a=a(3); %K/m
T(i)=T1+a.*(alt(i+1)-h1)
Prat(i)=(T(i)./T1).^-(go./(a.*R))
rhorat(i)=exp(1).^-(go./(a.*T(i))+1)
elseif alt>=79000 & alt<90000
T(i)=165.66 %K
Prat(i)=exp(1).^-(go./(R.*T(i)).*(alt(i)-h1))
rhorat(i)=Prat(i)
elseif alt>=90000 & alt<105000
a=a(1); %K/m
T(i)=T1+a.*(alt(i)-h1)
Prat(i)=(T(i)./T1).^-(go./(a.*R))
rhorat(i)=exp(1).^-(go./(a.*T(i))+1)
elseif alt==105000
T(i)=225.66; %K
Prat(i)=exp(1).^-(go./(R.*T(i)).*(alt(i)-h1))
rhorat(i)=Prat(i+1)
elseif alt<0 | alt>105000
fprintf('Error: This code only evaluates outputs within a range of 0-105000 meters\n')
end
P=P1.*Prat
rho=rho1.*rhorat
sigma=rho./rho1
i=i+1;
end