Plot earth atmospheric model
7 views (last 30 days)
Show older comments
Hello! Relatively new user here, im trying to plot the model of the atmosphere (density,temperature,speed of sound, vs altitude) as found here:
and here:
but im having trouble with the code, I dont really know what to do, that's why I am asking for a little help.The script runs but its not correct. I guess it is some kind of wrong usage of the if ifelse statements or even the way I created the height vector.
Any help would be appreciated. Thank you.
0 Comments
Accepted Answer
Sulaymon Eshkabilov
on 6 May 2019
Hi,
Note how to use conditional operators [if... elseif.. else..end] within [for ... end] loop. The equations you have taken are corrected w.r.t nasa.gov info. T used in formulation of the speed of sound has to be absolute tempreature and thus: T = temp + 273.1
Here is the complete answer code:
h=linspace(0,100000);
temp=zeros(size(h)); % Memory allocation
pressure=zeros(size(h)); % Memory allocation
for ii = 1:numel(h)
if h(ii)<11000
temp(ii)=15.04-0.00649*h(ii);
pressure(ii)=101.29*((temp(ii)+273.1)/288.08)^5.256;
elseif h(ii)>11000 && h(ii)<25000
temp(ii)=-56.46;
pressure(ii)=22.65.*exp(1.73-0.000157*h(ii));
else
temp(ii)=-131.21+0.00299*h(ii);
pressure(ii)=2.488*((temp(ii)+273.1)/216.6)^(-11.388);
end
end
dens=pressure./(0.2869*(temp+273.1));
T = temp+273.1;
speedofsound = sqrt(1.4*286*T);
figure(1);plot(h,temp, 'r-*'); grid on, title('temp')
figure(2);plot(h,dens, 'b-o'); grid on, title('dens')
figure(3);plot(h, speedofsound, 'g-.x'); grid on, title('speed of sound')
More Answers (0)
See Also
Categories
Find more on Polar Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!