For our solar system:
Surface temperature of the sun = 5780 K
Radius of sun = 6.96 * 10^8 m (or 6.96E8 m, alternatively)
1 AU = 1.49 * 10^11 m (or 1.49E11 m)
Code: Select all
% Temperature of a planetary body as a function of distance from a star
% T_s & R_s are the surface temperature and radius of the star respectively
T_s = input('Enter the Surface Temperature of the Star in Kelvin: ');
R_s = input('Enter the Radius of the Star in meters: ');
R_p = input('Enter the Distance from the Star to the Planet in meters (optional): ');
% AE is a factor having to do with a body's albedo and emissivity in the infrared.
% AE = sqrt((1-a)/e), where a = albedo and e = infrared emissivity.
AE = 1.1235^0.5; % this particular value would be an Earth-like planet, a = 0.4 and e = 0.534.
% R, orbital distance of a planet
R = 0:10000000:1.49E12;
% T(R)
T = T_s.*(R_s.*AE./(2.*R)).^0.5;
T_p = T_s.*(R_s.*AE./(2.*R_p)).^0.5;
% Habitable Zone
HZUT = 315 + 0.*R;
HZLT = 225 + 0.*R;
% Plotting T(R) and the habitable zone limits
plot(R,T,R,HZUT,R,HZLT,R_p,T_p,'o')
axis([0 1.49E12 0 2500])
title('Temperature vs Distance, R')
xlabel('Distance (1.49 * 10^8 km = 1 AU)')
ylabel('Temperature in Kelvin')
grid on
% checking to see if R_p was entered
DC = isempty(R_p);
if DC == 0
fprintf('The equilibrium temperature is %0.2f Kelvin at a distance of %0.2E meters.\n',T_p,R_p)
else
end