What might be wrong with the code?

1 Ansicht (letzte 30 Tage)
Sa Na
Sa Na am 28 Dez. 2021
Bearbeitet: Chunru am 28 Dez. 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.

Antworten (2)

KSSV
KSSV am 28 Dez. 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 am 28 Dez. 2021
Bearbeitet: Chunru am 28 Dez. 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 Kommentare
Chunru
Chunru am 28 Dez. 2021
See above.

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by