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')

类别

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