Example 1 – Nodal Analysis

advertisement
Example 1 – Nodal Analysis1
Use nodal analysis and Matlab to determine the node voltages in the following circuit.
Figure E1-1
Find the node voltages V1 and V2.
At node 1 we get
v1 − v2 v1
+
4
2
This equation can be written as 3v1 − v2 = 20
i1 = i2 + i3
or
5=
Similarly at note 2 we get
v1 − v2
v
i2 + i4 = i1 + i5 or
+ 10 = 5 + 2
4
6
This equation can be written as − 3v1 + 5v2 = 60
Thus we have two equations and two unknows. Putting these two in matrix form we can
 3 − 1  v1  20
write 
  =  
− 3 5  v2  60
This matrix equation is in the form of A ⋅ x = b where
v 
 3 − 1
20
A=
, x =  1  , and b =  

− 3 5 
60
v 2 
−1
−1
The solution to this matrix equation is x = A ⋅ b where A designates the inverse A
matrix.
In Matlab, the A matrix would be entered in the following form:
A = [3 -1; -3 5];
In Matlab matrices are entered by rows with semicolons to indicate the next row break.
The following m-file produces the answer.
1
This example is taken from Fundamentals of Electric Circuits, 2nd edition by Alexander and Sadiku, p. 80.
%Example1.m
A = [3 -1;-3 5];
b = [20 ; 60];
x = A^-1*b;
disp(x);
Figure E1-2
An m-file named Example1.m which diplays the result for this example.
The m-file is saved as Example1.m. From the command window we run the m-file to get
the following result.
>> example1
13.3333
20.0000
Download