Changing exponential axis scale
9 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Star Strider
2023 年 10 月 8 日
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 件のコメント
Star Strider
2023 年 10 月 8 日
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
2023 年 10 月 8 日
編集済み: Dyuman Joshi
2023 年 10 月 8 日
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.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Spectral Measurements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

