Line in Matlab plot do not appear

11 ビュー (過去 30 日間)
Nikolaos
Nikolaos 2024 年 5 月 4 日
コメント済み: Walter Roberson 2024 年 5 月 4 日
I am self studying Matlab and I want to create a plot with electron concentration and inverse temperature as the picture shows:
% Constants
k = 1.38e-23; % Boltzmann's constant (J/K)
Eg = 1.12; % Energy band gap of silicon (eV)
A = 2.5e19; % Constant for intrinsic carrier concentration calculation
Nc = 2.8e19; % Effective density of states in conduction band (cm^-3)
Nd = 1e16; % Doping concentration (cm^-3)
% Temperature range
T = linspace(100, 1000, 100); % Temperature range from 100 K to 1000 K
% Electron concentration for n-type doping
n = (Nc * Nv)^0.5 * exp(-Eg./(2*k*T));
% Calculate ln(n)
ln_n = log(n);
% Calculate 1/T
inv_T = 1 ./ T;
% Plot
plot(inv_T, ln_n, 'r', 'LineWidth', 2);
xlabel('1/T');
ylabel('ln(N_D)');
title('ln(Electron Concentration) vs. 1/T for Silicon');
grid on;
Does anyone knows ?
  1 件のコメント
Star Strider
Star Strider 2024 年 5 月 4 日
The ‘Nv’ definition is missing.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2024 年 5 月 4 日
移動済み: Walter Roberson 2024 年 5 月 4 日
Your exp() results in extremely small values, so you are getting NaN
Q = @(v) sym(v);
Nv = Q(1e23); %guess to run the program
% Constants
k = Q(1.38e-23); % Boltzmann's constant (J/K)
Eg = Q(1.12); % Energy band gap of silicon (eV)
A = Q(2.5e19); % Constant for intrinsic carrier concentration calculation
Nc = Q(2.8e19); % Effective density of states in conduction band (cm^-3)
Nd = Q(1e16); % Doping concentration (cm^-3)
% Temperature range
T = linspace(100, 1000, 100); % Temperature range from 100 K to 1000 K
% Electron concentration for n-type doping
n = (Nc * Nv)^0.5 * exp(-Eg./(2*k*T));
% Calculate ln(n)
ln_n = log(n);
% Calculate 1/T
inv_T = 1 ./ T;
TTTT = ln_n(1:2).'
TTTT = 
[vpa(TTTT(1)),vpa(TTTT(2))]
ans = 
double(TTTT)
Error using mupadengine/feval2char
Singularity.

Error in sym/double (line 755)
Xstr = feval2char(symengine, "symobj::double", S);
% Plot
plot(inv_T, ln_n, 'r', 'LineWidth', 2);
xlabel('1/T');
ylabel('ln(N_D)');
title('ln(Electron Concentration) vs. 1/T for Silicon');
grid on;
  1 件のコメント
Walter Roberson
Walter Roberson 2024 年 5 月 4 日
Doing the log operation directly:
Q = @(v) sym(v);
Nv = Q(1e23); %guess to run the program
% Constants
k = Q(1.38e-23); % Boltzmann's constant (J/K)
Eg = Q(1.12); % Energy band gap of silicon (eV)
A = Q(2.5e19); % Constant for intrinsic carrier concentration calculation
Nc = Q(2.8e19); % Effective density of states in conduction band (cm^-3)
Nd = Q(1e16); % Doping concentration (cm^-3)
% Temperature range
T = linspace(100, 1000, 100); % Temperature range from 100 K to 1000 K
% Electron concentration for n-type doping
ln_n = 0.5*log(Nc * Nv) + (-Eg./(2*k*T));
ln_n(1:5).'
ans = 
double(ans)
ans = 5x1
1.0e+20 * -4.0580 -3.7198 -3.4337 -3.1884 -2.9758
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% Calculate 1/T
inv_T = 1 ./ T;
% Plot
plot(inv_T, ln_n, 'r', 'LineWidth', 2);
xlabel('1/T');
ylabel('ln(N_D)');
title('ln(Electron Concentration) vs. 1/T for Silicon');
grid on;

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePole and Zero Locations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by