% circuit parametersr = round (100*rand (8,1)) V0 = round (100*RANDN)% Kirchoff ' S voltage lawa = [1 -1 0 0 0 1 -1 0 -1 0 1 0 0 -1 0 0 0 0 - 1 1 1 0 0 0 0 0 0 -1 -1 0 0 1]% symbolicallysymr = sym (' [r12 r13 r14 r23 r34 r25 r35 r45] ') ; R = a ' *diag (SYMR) *a% numerically r = a ' *diag (R) *a;b = [0 0 0 v0] ' i = r\[0 0 0 v0] '% kirchoff ' s current lawb = [1 -1 0 0 1 0 -1 0 1 0 0 -1 0 1 -1 0 0 0 1 -1 0 1 0 0 0 0 1 0 0 0 0 1]% symbolicallysymg = sym (' [G12 g13 g14  G23 G34 G25 G35 G45] '); G = b ' *diag (SYMG) *b% numerically g = 1./r;g35 = g (7); G = b ' *diag (g) *bc = [0 0 g35*v0 0] ' v = g\c% check Consistencyd = [0 0 0 0 0 0 v0 0] '; [(b*v-d)./(A*i) r]
The above MATLAB program has carried on the simulation and the simulation to the circuit characteristic.
The shape of the circuit diagram is this:
Where the current direction is clockwise.
Based on these parameters given in the circuit, combined with the KCl(kirchoff's current law), KVL(Kirchoff's voltage law ) to analyze it.
X = Randn Returns a random scalar drawn from the standard normal distribution.
Sym Create the symbolic variables
X = Rand Returns a single uniformly distributed random number in the interval (0,1).
X = rand (n) returns an n-by-n matrix of random numbers
The following statement returns a line vector consisting of a symbolic variable.
>> sym (' [R12 r13 R14 r23 r34 r25 r35 r45] ')
Ans =
[R12, R13, R14, R23, R34, R25, R35, R45]
Further analysis, put it in the diagonal position of the matrix, the resulting matrix is the shape of this:
>> symr = sym (' [R12 r13 R14 r23 r34 r25 r35 r45] ');
>> diag (SYMR)
Ans =
[R12, 0, 0, 0, 0, 0, 0, 0]
[0, R13, 0, 0, 0, 0, 0, 0]
[0, 0, R14, 0, 0, 0, 0, 0]
[0, 0, 0, r23, 0, 0, 0, 0]
[0, 0, 0, 0, R34, 0, 0, 0]
[0, 0, 0, 0, 0, R25, 0, 0]
[0, 0, 0, 0, 0, 0, R35, 0]
[0, 0, 0, 0, 0, 0, 0, R45]
>> A ' *diag (SYMR) *a
Ans =
[R12 + R14 + R25 + r45,-r12,-r14,-r45]
[-r12, R12 + R13 + r23,-r13, 0]
[-r14,-r13, R13 + R14 + R34,-r34]
[-r45, 0,-r34, R34 + R35 + r45]
The resistor matrix is obtained.
The analysis of the circuit by the programming realization