Changing exponential axis scale
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Star Strider
il 8 Ott 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 Commenti
Star Strider
il 8 Ott 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
il 8 Ott 2023
Modificato: Dyuman Joshi
il 8 Ott 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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Spectral Measurements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

