Page 123 - MATLAB an introduction with applications
P. 123
108 ——— MATLAB: An Introduction with Applications
i D
+
v D
–
Fig. E2.3
Solution:
MATLAB program for calculation of current flow in diode is given below:
% INITIAL VALUES
i0=2e–4; % leakage current in amp
k=1.38e–23; % Boltzmann constant (J/K)
q=1.602e–19; % charge of electron in C
vd=–0.2:0.01:0.25;% diode voltage (V)
t_f=[75 200 400]; % temperature in F
for ii=1:length(t_f)
t_k=(5/9)*(t_f(ii)–32)+273.15; %convert temperature to kelvin
id=i0.*(exp((q*vd)/(k*t_k))–1); %calculate diode current
if ii ==1
plot(vd,id,‘–o’); % plot lines in various ways
hold on;
elseif ii ==2
plot(vd,id,‘--’);
elseif ii==3
plot(vd,id,‘:o’);
hold off;
end
end
legend(‘75 deg F’,‘200 deg F’, ‘400 deg F’)
grid on;
title(‘\bf plot of diode voltage Vs diode current’);
xlabel(‘v_{D}’);
ylabel(‘i_{D}’);
F:\Final Book\Sanjay\IIIrd Printout\Dt. 10-03-09