Plot earth atmospheric model

조회 수: 5 (최근 30일)
Spyros T
Spyros T 2019년 4월 30일
댓글: Spyros T 2019년 5월 7일
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.

채택된 답변

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2019년 5월 6일
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')
  댓글 수: 1
Spyros T
Spyros T 2019년 5월 7일
Thank you very much for your help.
Runs great now!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by