blob: fe0e5d0ddfe8ff6dcb46acb5a79a9e6366b8877f (
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
|
// To determine the current using loop analysis
clc;
clear;
// MESH Equations
//6*i1-2*i2=30
//-2*i1+6*i2=-40
R=[6 -2;-2 6];
E=[30;-40];
//The Loop Currents
I=inv(R)*E; // Matrix Method to solve for two unknowns in two eaquations.
i1=I(1);
i2=I(2);
i3=i1-i2;
disp('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.')
if(i1<0);
i1=abs(i1);
end
if(i2<0);
i2=abs(i2);
end
disp('A',i1,'The Current through 4 ohm resistor on the 30V side =')
disp('A',i2,'The Current through 4 ohm resistor on the 40V side =')
disp('A',i3,'The Current through 2 ohm resistor =')
|