Consider the circuit diagram below Following the two rules T
Consider the circuit diagram below: Following the two rules: The voltage drop across a resistor is V = IR, The sum of all the voltage drops in a closed loop sum to zero, we can construct the following systems of equations: R_6I_1 + R_1(I_1 - I_2) + R_2(I_1 - I_3) = V_1, R_3I_2 + R_4(I_2 - I_3) + R_1(I_2 - I_1) = V_2, R_5I_3 + R_4(I_3 - I_2) + R_2(I_3 - I_1) = V_3. Let the resistances be given by R_1 = 10 Ohm, R_2 = 20 Ohm, R_3 = 5 Ohm, R_4 = 15 Ohm, R_5 = 30 Ohm and R_6 = 25 Ohm. (a) Write the equations in matrix form Ax = b (you need to do this by hand). Using the lu command in matlab, find matrices L, U and P such that PA = LU. Concatenate A, P, L and U in one 3 times 12 matrix and save it as A1.dat. (You don\'t know the voltage yet. Does that matter?) (b) Let V_1 = 50, V_2 = 0 and let V_3, vary from 1 to 100. For each value of V_3, calculate I_1, I_2 and I_3 using P, L and U. Save all of the results in a 3 times 100 matrix as A2.dat, with the order of the columns following that of V_3. (c) Repeat part (b), but use the inverse of A instead of L, U and P (using the command inv). This method should be slower, and the result should be slightly different. Subtract your results from parts (b) and (c), then save the absolute value of the difference as A3.dat. The answer should still be a 3 times 100 matrix.
Solution
a)
R1=30
R2=25
R3=20
r4=5
R4=5
R5=15
R6=10
V1=linspace(50,100,11)
A=[R6+R1+R2 -R1 -R3; -R1 R3+R4+R1 -R4; -R2 -R4 -R1+R4+R2]
A=[R6+R1+R2 -R1 -R3; -R1 R3+R4+R1 -R4; -R2 -R4 R1+R4+R2]
V2=10
V3=40
for i=1:12;
{
B=[V1(i) V2 V3]
B=B\'
X(;i)=A\\B
}
print,X
