Why isn't my MATLAB plot not showing up?

13 views (last 30 days)
It was supposed to show a plot of IV, but instead it just gives me blank plot. Code is given below.
clear;
clc;
close all;
Na= 10e17;
Nd=10e16;
ni=1e10;
ks=11.7; %dielectric constant for Si at 300K
E0=8.854e-14;
Es=ks*E0;
T1 = 300;
T2 = 400;
T3 = 500;
KB=1.38e-23;
q=1.6e-19;
Vbi_1 = (KB*T1*log(Na*Nd/(ni.^2)))/q;
Vbi_2 = (KB*T2*log(Na*Nd/(ni.^2)))/q;
Vbi_3 = (KB*T3*log(Na*Nd/(ni.^2)))/q;
Lp = 10e-3; %cm
Ln = 10e-3; %cm
A = 10e-4; %cm^2
Dp = ((Lp^2)/1e-5);
Dn = ((Ln^2)/1e-5);
I0 = (q.*A).*(((Dp./Lp).*((ni^2)./Nd)) + ((Dn./Ln).*((ni^2)./Na)));
I1 = I0.*(exp((q*Vbi_1)/(KB*T1)) -1);
I2 = I0.*(exp((q*Vbi_2)/(KB*T2)) -1);
I3 = I0.*(exp((q*Vbi_3)/(KB*T3)) -1);
Vbi = Vbi_1 : Vbi_2: Vbi_3;
I = I1 : I2: I3;
figure(1);
semilogy(Vbi,I0,'LineWidth',2);hold on
semilogy(Vbi,I,'LineWidth',2);
xlabel('Vbi[V]');
ylabel('I[A]')

Answers (2)

Athanasios Paraskevopoulos
Edited: Athanasios Paraskevopoulos on 12 Apr 2024
It looks like the issue with your MATLAB code is related to how you've set up the ranges for plotting the IV curves.
In MATLAB, when you define a range using the syntax start:step:end, the step value is crucial because it dictates how values are incremented from start to end. In your code, you have used:
Vbi = Vbi_1 : Vbi_2: Vbi_3;
I = I1 : I2: I3;
Here, Vbi_2 and I2 are being interpreted as step values, which is probably not what you intended. Given that Vbi_2 and I2 are likely much larger than the intended step sizes, this would result in Vbi and I arrays containing very few values, potentially even just one value, which can lead to a blank plot.
Here's how you can modify your code to fix these issues:
clear;
clc;
close all;
Na= 10e17;
Nd=10e16;
ni=1e10;
ks=11.7; %dielectric constant for Si at 300K
E0=8.854e-14;
Es=ks*E0;
T1 = 300;
T2 = 400;
T3 = 500;
KB=1.38e-23;
q=1.6e-19;
Vbi_1 = (KB*T1*log(Na*Nd/(ni.^2)))/q;
Vbi_2 = (KB*T2*log(Na*Nd/(ni.^2)))/q;
Vbi_3 = (KB*T3*log(Na*Nd/(ni.^2)))/q;
Lp = 10e-3; %cm
Ln = 10e-3; %cm
A = 10e-4; %cm^2
Dp = ((Lp^2)/1e-5);
Dn = ((Ln^2)/1e-5);
I0 = (q.*A).*(((Dp./Lp).*((ni^2)./Nd)) + ((Dn./Ln).*((ni^2)./Na)));
% Setup voltage sweep
Vbi = linspace(Vbi_1, Vbi_3, 100); % 100 points between Vbi_1 and Vbi_3
I = zeros(1, length(Vbi)); % Initialize I array
% Calculate current for each voltage
for k = 1:length(Vbi)
I(k) = I0.*(exp((q*Vbi(k))/(KB*T1)) -1);
end
% Plotting
figure(1);
semilogy(Vbi, I, 'LineWidth', 2);
xlabel('Vbi [V]');
ylabel('I [A]');
title('IV Characteristics');
grid on;
  2 Comments
AYESHA BINTE RAHMAN
AYESHA BINTE RAHMAN on 12 Apr 2024
thank you, now it's showing the plot. but the code was supposed to get 3 different curves for 3 different temperatures and all i am getting is one curve for 300K. Do you have any suggestion where should i modify the code?
Athanasios Paraskevopoulos
Do you mean something like that?
clear;
clc;
close all;
Na = 10e17; % Acceptor concentration
Nd = 10e16; % Donor concentration
ni = 1e10; % Intrinsic carrier concentration in Si at 300K
ks = 11.7; % Dielectric constant for Si at 300K
E0 = 8.854e-14; % Permittivity of free space
Es = ks * E0;
T = [300, 400, 500]; % Temperatures
KB = 1.38e-23; % Boltzmann constant
q = 1.6e-19; % Elementary charge
Vbi = zeros(3,1);
I0 = zeros(3,1);
for i = 1:length(T)
Vbi(i) = (KB * T(i) * log(Na * Nd / (ni.^2))) / q;
I0(i) = (q * 10e-4) * (((10e-3^2 / 1e-5) / 10e-3) * ((ni^2) / Nd) + ((10e-3^2 / 1e-5) / 10e-3) * ((ni^2) / Na));
end
% Setup voltage sweep
V = linspace(min(Vbi), max(Vbi), 100); % Voltage sweep from minimum to maximum built-in voltage
I = zeros(length(T), length(V)); % Initialize current array
% Calculate current for each voltage and temperature
for k = 1:length(V)
for j = 1:length(T)
I(j,k) = I0(j) * (exp((q * V(k)) / (KB * T(j))) - 1);
end
end
% Plotting
figure(1);
semilogy(V, I(1,:), 'b-', 'LineWidth', 2); hold on; % 300K curve
semilogy(V, I(2,:), 'r--', 'LineWidth', 2); % 400K curve
semilogy(V, I(3,:), 'k-.', 'LineWidth', 2); % 500K curve
xlabel('Vbi [V]');
ylabel('I [A]');
legend('300K', '400K', '500K');
title('IV Characteristics at Different Temperatures');
grid on;

Sign in to comment.


John D'Errico
John D'Errico on 12 Apr 2024
Edited: John D'Errico on 12 Apr 2024
A STRONG suggestion is when you do something, to look at the results of your code. Don't just give up when you see nothing in the plot, and then ask someone what is wrong? LOOK AT WHAT YOU DID! Think about it. I'm sorry, but this is crucial to you learning to program.
Na= 10e17;
Nd=10e16;
ni=1e10;
ks=11.7; %dielectric constant for Si at 300K
E0=8.854e-14;
Es=ks*E0;
T1 = 300;
T2 = 400;
T3 = 500;
KB=1.38e-23;
q=1.6e-19;
Vbi_1 = (KB*T1*log(Na*Nd/(ni.^2)))/q;
Vbi_2 = (KB*T2*log(Na*Nd/(ni.^2)))/q;
Vbi_3 = (KB*T3*log(Na*Nd/(ni.^2)))/q;
Lp = 10e-3; %cm
Ln = 10e-3; %cm
A = 10e-4; %cm^2
Dp = ((Lp^2)/1e-5);
Dn = ((Ln^2)/1e-5);
I0 = (q.*A).*(((Dp./Lp).*((ni^2)./Nd)) + ((Dn./Ln).*((ni^2)./Na)));
format long g % addinng this format statement so we can see all the digits
I1 = I0.*(exp((q*Vbi_1)/(KB*T1)) -1)
I1 =
0.176
I2 = I0.*(exp((q*Vbi_2)/(KB*T2)) -1)
I2 =
0.176000000000001
I3 = I0.*(exp((q*Vbi_3)/(KB*T3)) -1)
I3 =
0.176
So what are I1, I2, I3? THEY ARE THE SAME numbers! Virtually identically the same. I2 is actualy sloghtly larger then the others, but only by floating point trash.
What did you do with them?
I = I1 : I2: I3
I =
0.176
What did you expect as a result?
How about Vbi_1, etc?
[Vbi_1,Vbi_2,Vbi_3]
ans = 1x3
0.893690839218314 1.19158778562442 1.48948473203052
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
What do you think this does? It generates a vector of elements, starting from Vbi_1, with a stride of Vbi_2, as far out as Vbi_3.
Vbi = Vbi_1 : Vbi_2: Vbi_3
Vbi =
0.893690839218314
But, since Vbi_1 + Vbi_2 is actually greater than the end point, it just generates a scalar.
So what plot did you expect to see? You plotted one (SCALAR) number versus another, but then increased the linewidth. There was no line.

Categories

Find more on Graphics Performance 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!