Changing exponential axis scale

조회 수: 9 (최근 30일)
Craig
Craig 2023년 10월 8일
편집: Dyuman Joshi 2023년 10월 8일
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');

채택된 답변

Star Strider
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
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
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 CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by