Problem in simulating if condition

2 次查看(过去 30 天)
When I am trying to simulate , it is only taking one codition. The other condition it is not taking.
gd=2;
Ecd=0.045;
k=8.617e-5;
ni=1e10;
T=linspace(0,600,100);
mee=0.553*9.11e-31;
meh=0.357*9.11e-31;
Nc=((2.510e19)*((0.553)^1.5).*((T/300).^1.5));
Nv=((2.510e19)*((0.357)^1.5).*((T/300).^1.5));
display(Nc)
display(Nv)
Nj=(Nc/gd).*(exp(-Ecd./(k.*T)));
display(Nj)
Nd=1e15;
Eg0=0.7437;
a=4.77e-4;
b=235;
Eg=Eg0-((a*(T.^2))./(T+b));
display(Eg)
ni=((sqrt(Nc.*Nv)).*(exp((-Eg)./(2*k.*T))));
if (T>300)
n=(Nd/2)+(sqrt(((Nd/2)^2)+(ni.^2)));
else
n=((Nj/2).*((sqrt(1+((4*Nd)./(Nj))))-1));
end
plot(T,n/Nd,'g','linewidth',2)
plot(T, ni/Nd,'--r','linewidth',2)
grid on
xlabel('Temperature in K')
ylabel('n/Nd')
title('Temp. dependence of Majority Carrier Concentration')
set(gca,'ylim',[0 3],'xlim', [0 610])
  2 个评论
SWASTIK SAHOO
SWASTIK SAHOO 2020-10-3
I am not getting the curve where it is increasing with temperature. I am only getting saturated value..
Thank you so much for your help.
gd=2;
Ecd=0.045;
k=8.617e-5;
ni=1e10;
T=linspace(0,600,100);
mee=0.553*9.11e-31;
meh=0.357*9.11e-31;
Nc=((2.510e19)*((0.553)^1.5).*((T/300).^1.5));
Nv=((2.510e19)*((0.357)^1.5).*((T/300).^1.5));
display(Nc)
display(Nv)
Nj=(Nc/gd).*(exp(-Ecd./(k.*T)));
display(Nj)
Nd=1e15;
Eg0=0.7437;
a=4.77e-4;
b=235;
Eg=Eg0-((a*(T.^2))./(T+b));
display(Eg)
ni=((sqrt(Nc.*Nv)).*(exp((-Eg)./(2*k.*T))));
if (T>300)
n=(Nd/2)+(sqrt(((Nd/2)^2)+ni.^2));
else
n=((Nj/2).*((sqrt(1+((4*Nd)./(Nj))))-1));
end
plot(T,n/Nd,'b','linewidth',2)
%plot(T,n1/Nd,'b','linewidth',2)
display(n)
display(n/Nd)
display(ni/Nd)
%plot(T,n/Nd,'b','linewidth',2)
hold on
plot(T, ni/Nd,'--r','linewidth',2)
%plot(T,n1/Nd,'b','linewidth',2)
hold off
grid on
xlabel('Temperature in K')
ylabel('n/Nd')
title('Temp. dependence of Majority Carrier Concentration')
set(gca,'ylim',[0 3],'xlim', [0 610])
legend('n/Nd', 'ni/Nd')
Alan Stevens
Alan Stevens 2020-10-3
编辑:Alan Stevens 2020-10-3
I was too quick off the mark. You were right, your "if" functions don't work properly! See below.

请先登录,再进行评论。

采纳的回答

Alan Stevens
Alan Stevens 2020-10-3
编辑:Alan Stevens 2020-10-3
You can replace your if statement with
% Assuming there are 100 steps in T
nhi=(Nd/2)+(sqrt(((Nd/2)^2)+(ni(51:100).^2)));
nlo=((Nj(1:50)/2).*((sqrt(1+((4*Nd)./(Nj(1:50)))))-1));
n = [nlo, nhi];
Also replace
plot(T,n/Nd,'g','linewidth',2)
plot(T, ni/Nd,'--r','linewidth',2)
with
plot(T,n/Nd,'g','linewidth',2)
hold on
plot(T, ni/Nd,'--r','linewidth',2)
if you want both curves on the same plot.
The following is the result
  2 个评论
SWASTIK SAHOO
SWASTIK SAHOO 2020-10-3
Do I need to prespecify nhi, nlo???It is showing Unrecognized variable or function "nhi"
Alan Stevens
Alan Stevens 2020-10-3
Like so:
gd=2;
Ecd=0.045;
k=8.617e-5;
%
%ni=1e10;
T=linspace(0,600,100);
mee=0.553*9.11e-31;
meh=0.357*9.11e-31;
Nc=((2.510e19)*((0.553)^1.5).*((T/300).^1.5));
Nv=((2.510e19)*((0.357)^1.5).*((T/300).^1.5));
% display(Nc);
% display(Nv);
Nj=(Nc/gd).*(exp(-Ecd./(k.*T)));
% display(Nj);
Nd=1e15;
Eg0=0.7437;
a=4.77e-4;
b=235;
Eg=Eg0-((a*(T.^2))./(T+b));
% display(Eg);
ni=((sqrt(Nc.*Nv)).*(exp((-Eg)./(2*k.*T))));
% Assuming there are 100 steps in T
nhi=(Nd/2)+(sqrt(((Nd/2)^2)+(ni(51:100).^2)));
nlo=((Nj(1:50)/2).*((sqrt(1+((4*Nd)./(Nj(1:50)))))-1));
n = [nlo, nhi];
plot(T,n/Nd,'g','linewidth',2)
hold on
plot(T, ni/Nd,'--r','linewidth',2)
grid on
xlabel('Temperature in K')
ylabel('n/Nd')
title('Temp. dependence of Majority Carrier Concentration')
set(gca,'ylim',[0 3],'xlim', [0 610])

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Filter Banks 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by