Changing exponential axis scale
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a graph with x-axis scale e-6 but I want the scale to be e-9. When I use the code ax = gca and then ax.XAxis.Exponent = -9, the x-axis scale becomes e2147483647. How can I get the x-axis to become e-9? Please see code below.
c = 3e+08; % Speed of light in m/s
h = 6.63e-34; % Planck's constant in Js
k = 1.38e-23; % Boltzmann's constant in J/K
T = 5973.15; % Temperature in K
y = 0:10e-9:2000e-9; % Wavelength in m
R = ((2*pi*h*c^2)./y.^5).*(1./(exp((h*c)./(k*T*y))-1)); % Spectral Irridiance in W/m^2/m
plot(y,R)
xlabel({'Wavelength','(nm)'});
ylabel({'Spectral Irridiance','(W/m^2/nm)'});
title('Black Body Radiation Spectrum at 5700 Degrees Celcius');
0 commentaires
Réponse acceptée
Star Strider
le 8 Oct 2023
I am not certain what the problem is.
The approach you took appears to work here (R2023b) —
c = 3e+08; % Speed of light in m/s
h = 6.63e-34; % Planck's constant in Js
k = 1.38e-23; % Boltzmann's constant in J/K
T = 5973.15; % Temperature in K
y = 0:10e-9:2000e-9; % Wavelength in m
R = ((2*pi*h*c^2)./y.^5).*(1./(exp((h*c)./(k*T*y))-1)); % Spectral Irridiance in W/m^2/m
plot(y,R)
xlabel({'Wavelength','(nm)'});
ylabel({'Spectral Irridiance','(W/m^2/nm)'});
title('Black Body Radiation Spectrum at 5700 Degrees Celcius');
ax = gca;
ax.XAxis.Exponent = -9;
.
3 commentaires
Star Strider
le 8 Oct 2023
As always, my pleasure!
I just now ran it in MATLAB Online (R2023b). It worked correctly, giving the same results as depicted here.
Dyuman Joshi
le 8 Oct 2023
Modifié(e) : Dyuman Joshi
le 8 Oct 2023
MATLAB Online has the same version as MATLAB Answers i.e. R2023b. You should not have any problems there. (Type "ver" in the command window to check)
Also, @Craig, if the wavelength is in meters, and the unit of x-axis is nano-meter, the xtick values should be adjusted accordingly as well no.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spectral Measurements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

