필터 지우기
필터 지우기

What might be wrong with the code?

조회 수: 1 (최근 30일)
Sa Na
Sa Na 2021년 12월 28일
편집: Chunru 2021년 12월 28일
What might be wrong with the code ,it generates a straight line which is not required.
% The Boltzman Equation
E1=-13.6;
E2=-3.4;
k=8.617*10.^-5;
g1=2;
g2=8;
T=[5000;10000;15000;20000;25000];
N=[0.001;0.002;0.003;0.004;0.005];
% N=g2/g1*exp(-(E2-E1)/k*T);
set(gca,'xTicklabel',[5000 10000 15000 20000 25000]);
axis([5000 25000 0 0.05]);
xlabel('T')
ylabel('N2/N1')
plot(T,N);
The graph in the picture is required.

답변 (2개)

KSSV
KSSV 2021년 12월 28일
% The Boltzman Equation
E1=-13.6;
E2=-3.4;
k=8.617*10.^-5;
g1=2;
g2=8;
% T=[5000;10000;15000;20000;25000];
T = linspace(5000,25000) ;
% N=[0.001;0.002;0.003;0.004;0.005];
N=(g2/g1)*exp(-(E2-E1)./(k*T));
set(gca,'xTicklabel',[5000 10000 15000 20000 25000]);
axis([5000 25000 0 0.05]);
xlabel('T')
ylabel('N2/N1')
plot(T,N);

Chunru
Chunru 2021년 12월 28일
편집: Chunru 2021년 12월 28일
The data you plot is a straight line. The expected data should be something shown below.
E1=-13.6;
E2=-3.4;
k=8.617*10.^-5;
g1=2;
g2=8;
T=[5000:1000:25000];
%N=[0.001;0.002;0.003;0.004;0.005];
N=g2/g1*exp(-(E2-E1)./(k*T));
plot(T,N);
% set(gca,'xTicklabel',[5000 10000 15000 20000 25000]);
% axis([5000 25000 0 0.05]);
xlabel('T')
ylabel('N2/N1')
ax = gca; ax.XAxis.Exponent = 0;
%xtickformat('%g')
  댓글 수: 3
Chunru
Chunru 2021년 12월 28일
See above.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by