Вы находитесь на странице: 1из 2

Linear Circuit Analysis with MATLAB

Given AX=B represents the simultaneous linear equations of an electric circuit with
a11 a12 a13   b1 

A = a21 a22 a23   B = b2 
a31 a32 a33  b3 
Create A and B in MATLAB script as follows:
A=[ a11 a12 a13; a21 a22 a23; a31 a32 a33];
B=[b1; b2; b3];
The solution X can be obtained as:
X = A−1B
This is computed using the in-built inverse matrix function of in MATLAB as follows
X = inv ( A) * B ;
This generates simultaneously the elements of the unknown vector X.
If any of the elements of the unknown vector X is desired, Cramer’s rule can be used.
 ∆1 
1 
X =  ∆2 
∆ 
 ∆3 
a11 a12 a13
∆ = a21 a22 a23
a31 a32 a33
b1 a12 a13
∆1 = b2 a22 a23
b3 a32 a33
a11 b1 a13
∆ 2 = a21 b2 a23
a31 b3 a33
a11 a12 b1
∆ 3 = a21 a22 b2
a31 a32 b3
∆ , ∆1 , ∆ 2 and ∆ 3 are determinants which are computed using MATLAB in-built function.
Let A1, A2 and A3 be matrices associated with the determinants ∆1 , ∆ 2 and ∆ 3 . These
matrices can be created as and defined as:
A1=[ b1 a12 a13; b2 a22 a23; b3 a32 a33]; or A1=[ B A(1:3,2) A(1:3,3)];% replace column 1 with B
A2=[ a11 b1 a13; a21 b2 a23; a31 b3 a33]; or A2=[ A(1:3,1) B A(1:3,3)]; % replace column 2 with B
A3=[ a11 a12 b1; a21 a22 b2; a31 a32 b3]; or A3=[ A(1:3,1) A(1:3,2) B]; % replace column 3 with B

Hence the determinants are computed in MATLAB as:

Page 1 of 2
∆ = det( A)
∆1 = det( A1 )
∆ 2 = det( A2 )
∆3 = det( A3 )
From which the individual unknown elements of the vector X are computed.

Exercise 1
R1 1 i2

i1
R3 R2

i3
R4 i4
E 3 2
i6 i5
R6 R5

Given that in Figure 1 R1=2Ω, R2=4Ω, R3=2Ω, R4=3Ω, R5=2Ω, R6=4Ω and E=10V,
(a) Create m-file to calculate the mesh and branch currents using mesh analysis.
(b) Create m-file to calculate the node voltages and branch currents using nodal analysis
(c) Compare results computed using inverse matrix and Cramer’s Rule

Exercise 2
In the network shown below, R1=5Ω, R2=12Ω, R3=10Ω, R4=8Ω, R5=15Ω, E1=4V and E2=6V.

R1 R3

R5 R2 R4
E1
E2

(a) Create m-file to calculate the mesh and branch currents using mesh analysis.
(b) Create m-file to calculate the node voltages and branch currents using nodal analysis
(c) Compare results computed using inverse matrix and Cramer’s Rule

Page 2 of 2

Вам также может понравиться