summaryrefslogtreecommitdiff
path: root/1445/CH1/EX1.33/ch1_ex_33.sce
blob: 35f0b1417534a023abd7e5a2d149a529ddd79a4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//CHAPTER 1- D.C. CIRCUIT ANALYSIS AND NETWORK THEOREMS 
//Example 33

disp("CHAPTER 1");
disp("EXAMPLE 33");

//VARIABLE INITIALIZATION
I=10;                           //current source in Amperes
v=10;                           //voltage source in Volts
r1=4;                           //top resistance in Ohms
r1=4;                           //right resistance in Ohms
r3=4;                           //bottom resistance in Ohms
r4=6;                           //left resistance in Ohms
r5=1;                           //in Ohms

//SOLUTION
//(17)v1+(-12)v2=150.......eq (1)
//(-4)v1+(6)v2=10..........eq (2)
//solving the equations by matrix method
A=[17 -12;-4 6];
b=[150;10];
x=inv(A)*b;
v1=x(1,:);                       //to access the 1st element of 2X1 matrix
v2=x(2,:);                       //to access the 1st element of 2X1 matrix
if(v1>v2) then
I=(v1-v2)/r5;
disp(sprintf("By Nodal analysis, the current through 1Ω resistor is %f A",I));
else
I=(v2-v1)/r5;
disp(sprintf("By Nodal analysis, the current through 1Ω resistor is %f A",I));
end;

//END