summaryrefslogtreecommitdiff
path: root/45/CH14/EX14.1/example_14_1.sce
blob: d3ef4d09411d65f47dc0fc666d07f2425d5d8f14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//example 14.1
clc;
clear;
close; 
vdc = input('Enter the value of DC voltage Vdc in volts :');
r = input('Enter the value of resistace in K ohms :');
v = input(' Enter the value of voltage across diode in volts :');

i = (vdc-v)/r ;
format('v',4);
if(i>0)  // checking whether the diode is forward or reverse biased by checking current 
    disp('The diode is in forward bias');
    disp('The diode current in mA is :');
    disp(i);
else
    disp('The diode is in Reverse bias');
    disp('The diode current in mA is : 0.0');
end;