summaryrefslogtreecommitdiff
path: root/1319/CH2/EX2.3/2_3.sce
blob: d2e6cfa8e94a8a9430e3b5f9163bebfa143eea38 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// To calculate current in each branch using loop analysis and point voltages in a given network.

clc;
clear;

// MESH Equations for the given network.
//3.95*i1-3.75*i2+0*i3=120
//-3.75*i1+9.5*i2-5.45*i3=0
//0*i1-5.45*i2+5.55*i3=-110

// Positive of 120V DC supply connected to 0.2 ohm resistor
// Positive of 110 DC supply connected to 0.1 ohm resistor

//Voltage supplies are 120V and 110V

R=[3.95 -3.75 0;-3.75 9.5 -5.45; 0 -5.45 5.55];
E=[120;0;-110];

R1=abs(R(2)); // Resistor carrying ia
R2=abs(R(8)); // Resistor carrying ib

// Loop Currents

I=inv(R)*E;

i1=I(1);
i2=I(2);
i3=I(3);

ia=i1-i2; // Assumed direction from Mesh 1
ib=i2-i3; // Assumed direction from Mesh 2

// Using Nodal Analysis to find V1 and V2.
V1=R1*ia;
V2=R2*ib;

disp('A',ib,'ib (through 2 resistor between 7 ohm and 3 ohm resistor) =','A',ia,'ia(through 1 ohm resistor) =','A',i3,'i3 =','A',i2,'i2 =','A',i1,'i1 =','The Calculated Loop Currents are')

disp('The Negative sign indicates that the assumed direction of flow of current should be reveresed')

// To obtain the magnitude of direction.

if(i1<0)
    i1=abs(i1);
end
if(i2<0)
    i2=abs(i2);
end
if(i3<0)
    i3=abs(i3);
end
if(ia<0)
    ia=abs(ia);
end
if(ib<0)
    ib=abs(ib);
end

disp('A',i1,'The Current through 0.2 ohm resistor on the 120V side =')
disp('A',i2,'The Current through 0.3 ohm resistor =')
disp('A',i3,'The Current through 0.1 ohm resistor on the 110V side =')
disp('A',ia,'The Current through 3.75 ohm resistor =')
disp('A',ib,'The Current through 5.45 ohm resistor =')

disp('V',V1,'The voltage V1 =')
disp('V',V2,'The voltage V2 =')