My table does not appear properly in my code

1 visualización (últimos 30 días)
Daniel Martelli
Daniel Martelli el 24 de Sept. de 2020
% Problem 1
% part (a)
Re = 6356.766; % km earth radius
Rs = 0.287053; % kJ/K/kg 287.053 J/K/kg
B = 34.1632; % K/km exponent constant
% ai = [diff(Ti)./diff(hi),0]
% heights (km) (K) slopes (K/km)
% --------------------------------------------------------------------------------
h1 = 0; T1 = 288.15; a1 = -6.5; % troposphere
h2 = 11; T2 = 216.65; a2 = 0; % tropopause
h3 = 20; T3 = 216.65; a3 = 1; % stratosphere
h4 = 32; T4 = 228.65; a4 = 2.8; % stratosphere
h5 = 47; T5 = 270.65; a5 = 0; % stratopause
h6 = 51; T6 = 270.65; a6 = -2.8; % mesosphere
h7 = 71; T7 = 214.65; a7 = -2; % mesosphere
h8 = 84.852; T8 = 186.946; a8 = 0; % mesopause
h9 = 90; T9 = 186.946; % mesopause
hi = [h1, h2, h3, h4, h5, h6, h7, h8, h9];
zi = Re*hi./(Re-hi);
ai = [a1, a2, a3, a4, a5, a6, a7, a8];
Ti = [T1, T2, T3, T4, T5, T6, T7, T8, T9];
f = @(h,Ti,hi,ai) (ai~=0) * (1 + ai/Ti*(h-hi)).^(-B*pinv(ai)) + (ai==0) * exp(-B/Ti*(h-hi));
P1 = 101325; % P = Pressure, SI unit = N/m^2
P2 = f(h2, T1, h1, a1) * P1;
P3 = f(h3, T2, h2, a2) * P2;
P4 = f(h4, T3, h3, a3) * P3;
P5 = f(h5, T4, h4, a4) * P4;
P6 = f(h6, T5, h5, a5) * P5;
P7 = f(h7, T6, h6, a6) * P6;
P8 = f(h8, T7, h7, a7) * P7;
P9 = f(h9, T8, h8, a8) * P8;
Pi = [P1, P2, P3, P4, P5, P6, P7, P8, P9];
rhoi = Pi./Ti/Rs/1000; % this is divided by 1000 because Rs is in kJ/K/kg
L = {'troposphere', 'tropopause', 'stratosphere', 'stratosphere', 'stratopause', ...,
'mesosphere', 'mesosphere', 'mesopause', 'mesopause'};
C = [L, num2cell([hi,zi,Ti,ai,Pi,rhoi])]';
disp(' ');
fprintf(' Atmospheric hi zi Ti ai Pi rhoi\n');
fprintf(' Layer (km) (km) (K) (K/km) (Pa) (kg/m^3)\n');
fprintf('---------------------------------------------------------------------------\n');
fprintf('%12s %6.3f %6.3f %7.3f %4.1f %11.4f %5.5g\n', C{:});
% part (b)
T = @(h) (T1 + a1*(h-h1)) .* (h>=h1 & h<h2) + ... % troposphere
(T2 + a2*(h-h2)) .* (h>=h2 & h<h3) + ... % tropopause
(T3 + a3*(h-h3)) .* (h>=h3 & h<h4) + ... % stratosphere
(T4 + a4*(h-h4)) .* (h>=h4 & h<h5) + ... % stratosphere
(T5 + a5*(h-h5)) .* (h>=h5 & h<h6) + ... % stratopause
(T6 + a6*(h-h6)) .* (h>=h6 & h<h7) + ... % mesosphere
(T7 + a7*(h-h7)) .* (h>=h7 & h<h8) + ... % mesosphere
(T8 + a8*(h-h8)) .* (h>=h8); % mesopause, valid till h = 90 km
P = @(h) P1 * f(h, T1, h1, a1) .* (h>=h1 & h<h2) + ...
P2 * f(h, T2, h2, a2) .* (h>=h2 & h<h3) + ...
P3 * f(h, T3, h3, a3) .* (h>=h3 & h<h4) + ...
P4 * f(h, T4, h4, a4) .* (h>=h4 & h<h5) + ...
P5 * f(h, T5, h5, a5) .* (h>=h5 & h<h6) + ...
P6 * f(h, T6, h6, a6) .* (h>=h6 & h<h7) + ...
P7 * f(h, T7, h7, a7) .* (h>=h7 & h<h8) + ...
P8 * f(h, T8, h8, a8) .* (h>=h8);
rho = @(h) P(h)./T(h)/Rs/1000;
% part (c)
h = 0:0.1:90;
figure;
plot(h,T(h),'b-',hi,Ti,'r.','markersize',20)
xlabel('{\ith} (km)'); ylabel('{\itT} (K)');
title('Standard Temperature Layers');
figure; semilogy(h,P(h),'b-', hi,Pi,'r.','markersize',20);
xlabel ('{\ith} (km)'); ylabel('{\itP} (Pa)');
title ('Pressure vs Height');
legend ('pressure', 'thresholds', 'location', 'ne');
figure; semilogy(h,rho(h),'b-', hi,rhoi,'r.','markersize',20);
xlabel('{\ith} (km)'); ylabel('{\it\rho} (kg/m^3)');
title('Air Density vs Height');
legend('density', 'thresholds', 'location','ne');
I have tried a few different things to try and fix the table, but nothing is working

Respuestas (0)

Categorías

Más información sobre Unit Conversions en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by