What might be wrong with the code?

1 visualización (últimos 30 días)
Sa Na
Sa Na el 28 de Dic. de 2021
Editada: Chunru el 28 de Dic. de 2021
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.

Respuestas (2)

KSSV
KSSV el 28 de Dic. de 2021
% 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 el 28 de Dic. de 2021
Editada: Chunru el 28 de Dic. de 2021
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 comentarios
Chunru
Chunru el 28 de Dic. de 2021
See above.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by