MATLAB: Hey, I want to plot the V-I characteristics of Germanium against voltage. but matlab is not showing the plot. Can anyone help what is the problem in code

for loopplot

clear all
clc
T= 25+273;
q=1.602*10^-19;
k=1.38*10^-23;
i0=10^-4;
for v=-1:0.1:1
v
id=i0*[exp((q*v)/(k*T))-1];
plot(v,id)
end

Best Answer

Use MATLAB’s vectorization capability, and you can do it without the loop:
T= 25+273;
q=1.602E-19;
k=1.38E-23;
i0=1E-4;
v=linspace(-1,1);
id=i0*[exp((q*v)/(k*T))-1];
plot(v,id)
I also made one minor change, that being to use the linspace function rather than the colon operator to produce a smoother plot.
Related Question