Clear Filters
Clear Filters

Problem in simulating if condition

2 views (last 30 days)
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 Comments
SWASTIK SAHOO
SWASTIK SAHOO on 3 Oct 2020
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 on 3 Oct 2020
Edited: Alan Stevens on 3 Oct 2020
I was too quick off the mark. You were right, your "if" functions don't work properly! See below.

Sign in to comment.

Accepted Answer

Alan Stevens
Alan Stevens on 3 Oct 2020
Edited: Alan Stevens on 3 Oct 2020
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 Comments
SWASTIK SAHOO
SWASTIK SAHOO on 3 Oct 2020
Do I need to prespecify nhi, nlo???It is showing Unrecognized variable or function "nhi"
Alan Stevens
Alan Stevens on 3 Oct 2020
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])

Sign in to comment.

More Answers (0)

Categories

Find more on Filter Banks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!