////// parameters ////// h = 4.135667662*10^-15; c = 299792458; k = 8.6173303*10^-5; lambda1 = 380*10^-9; lambda2 = 740*10^-9; T_sun = 5778.; T_light_bulb = 2800.; ////// functions ////// // Planck' s law : spectral energy density function energy_density = spectral_energy_density(lambda, T) energy_density = 8*%pi*h*c/lambda^5*1/(exp(h*c/(k*T*lambda))-1) endfunction // Stefan-Boltzmann law : total energy density function energy_density = total_energy_density(T) energy_density = 8*%pi^5*k^4*T^4/(15*h^3*c^3) endfunction // energy density in the visible spectrum function energy_density = visible_energy_density(T) energy_density = integrate('spectral_energy_density(lambda, T)', 'lambda', lambda1, lambda2, 1e-4) endfunction // fraction of the energy density in the visible spectrum function fractionI = fraction_in_visible_spectrum(T) fractionI = visible_energy_density(T) / total_energy_density(T) endfunction // get a list of the energy fractions between the temperatures T1 and T2 in steps of Tstep function [T, fT] = get_energy_fractions(T1, T2, Tstep) T = [T1:Tstep:T2]; fT = T; for i = 1:length(fT); fT(i) = fraction_in_visible_spectrum(T(i)); end endfunction // find the maximum of y = f(x), where x and y are lists function [max_x, max_y] = get_list_maximum(x, y) max_y = max(y); index = find(y == max_y); max_x = x(index); endfunction ////// main ////// // find the temperature, for which the energy fraction in the visible spectrum is maximal [T, fT] = get_energy_fractions(6500., 7500., 0.1); [T_max, fT_max] = get_list_maximum(T, fT); // plot the results [T, fT] = get_energy_fractions(1000., 20000., 10.); plot(T, fT); xtitle("", "temperature [K]", "energy fraction in visible spectrum"); gca().auto_clear = "off"; plot(T_max, fT_max, 'r-o'); // compare energy fraction of T_max, T_sun, and T_light_bulb fraction_sun = fraction_in_visible_spectrum(T_sun); fraction_light_bulb = fraction_in_visible_spectrum(T_light_bulb); printf('\n\n'); printf('comparison of the energy fractions in the visible spectrum:\n\n'); printf('\t maximal energy fraction (%.0f K): %i %% \n', T_max , round(fT_max*100)); printf('\t sun (%.0f K): %i %% \n' , T_sun , round(fraction_sun*100)); printf('\t light bulb (%.0f K): %i %% ' , T_light_bulb, round(fraction_light_bulb*100)); printf('\n\n');