function p=barometric(p0,z,T)
% computs pressure from barometric equation
% p0- pressure ad surface
% z - altitude in meters
% T - temperature in K
% z and T can be scalar or vector
g=9.81;
R=287;
if length(z)==1
 p=p0*exp(-g*z/(R.*T));
else
 p(1)=p0;   
 for k=2:length(z)   
  p(k)=p0*exp(-g/R*trapz(z(1:k),1./T(1:k)));   
 end
end    
