Diode Circuit

%DIODE.m  A diode circuit.
%       This is an example of how to solve graphically a nonlinear
%       problem. To obtain hardcopies delete the comment signs, %,
%       preceding the PRINT statements. If you wish longer display
%       times, change the argument, 5, of the command PAUSE.

I0 = 1.0E-6;    % mA
Vs = 10;        % V
R = 2000;       % ohm
Dx = -0.05: 0.005: 0.05;
Dy = I0*(exp(40*Dx) – 1);
plot(Dx, Dy), grid
title(‘Characteristic of semiconductor diode’)
xlabel(‘Voltage v, V’), ylabel(‘Current i, mA’)
pause(5)
% print
Dx = -1.0: 0.05: 0.25;
Dy = I0*(exp(40*Dx) – 1);
plot(Dx, Dy), grid
title(‘Characteristic of semiconductor diode’)
xlabel(‘Voltage v, V’), ylabel(‘Current i, mA’)
pause(5)
% print
Dx = -10: 0.05: 0.8;
Dy = I0*(exp(40*Dx) – 1);
plot(Dx, Dy), grid
title(‘Characteristic of semiconductor diode’)
xlabel(‘Voltage v, V’), ylabel(‘Current i, mA’)
pause(5)
% print
Dx = 0: 0.05: 0.4;
Dy = I0*(exp(40*Dx) – 1);
Cx = [ 0 0.39 ];
Cy = 1000*(Vs – Cx)/R;
plot(Dx, Dy, Cx, Cy), grid
title(‘Operating point of resistor-diode circuit’)
xlabel(‘Voltage v, V’), ylabel(‘Current i, mA’)
pause(5)
% print
t = 0: 0.0001: 0.05;
v = 0.4*sin(2*pi*50*t);
i = I0*(exp(40*v) – 1);
plot(t, i), grid
title(‘The diode as a half-wave rectifier’)
xlabel(‘Time, s’), ylabel(‘Current, mA’)
% print w