How Do I Solve Kirchhoff's Loop Rule Problem in MATLAB?

  • Thread starter lee_sarah76
  • Start date
  • Tags
    Loop
In summary: As long as the equations are consistent with each other and don't affect each others' definitions, it all works out. (And it can save a bit of time and effort, too.) In summary, the conversation discussed the steps and attempts at solving a circuit problem involving Kirchhoff's Loop Rule and using matrix methods with MATLAB. The correct mesh current values were obtained, but there was confusion about the physics and software behind the solution due to an extra, unnecessary equation for the fifth loop. However, this did not affect the overall solution and it was noted that matrix methods can be useful in solving multiple problems at once.
  • #1
lee_sarah76
18
0

Homework Statement



So, I understand that I'm supposed to write the problem however, given the nature of current diagrams I think this is a bit hard. I am given the voltages and resistances and I have to solve for the current through each resistor. Here is a link to the problem which I found online if you wouldn't mind: http://cs.slu.edu/~fritts/csci145/assignments/hwk3.pdf

It is number 6 on that website.

V1 = 12V, V2 = 24V, R1 = 20 ohms, R2 = 12, R3 = 8 ohms, R4 = 6 ohms, R5 = 10 ohms


Homework Equations



Kirchhoff's Loop Rule states that the sum of the voltages in a closed loop equals 0.

The Attempt at a Solution



After using Kirchhoff's Loop Rule 5 times I ended up with these set of equations:

V1 - R1(I1 - I3) - R2(I1 - I2) = 0
V2 - R1(I3 - I1) - R3(I3) = 0
-V2 - R2(I2 - I1) - R4(I2 - I4) = 0
0 - R5(I4) - R4(I4 - I2) = 0
V1 - R3(I5 +I3) - R5(I5) =0

However, when using a matrix to solve for I1 through I5, I get: 1.26667, -0.55873, 1.7619, -0.20952, -0.11640.

(Note: I used MATLAB, as this is for a programming class, and my matrices were:
A = [-(R1 + R2), R2, R1, 0, 0; R2, -(R2+R4), 0, R4, 0; R1, 0, -(R1 +R3), 0, 0; 0, R4, 0, -(R5 + R4), 0; 0, 0, -R3, 0, -(R3 + R5)]

B = [-V1; V2; -V2; 0; -V1]

and x = A\B

Obviously, this is not the answer according to the website that the problem statement was on. I believe I am doing something wrong with Kirchhoff's Rule, hence I would be very grateful if someone could help?
 
Physics news on Phys.org
  • #2
Where and in what direction are your currents defined to be?

If the current In is the current through resistor "n" then this

V1 - r1(i1 - i3) - r2(i1 - i2) = 0

appears wrong to me.

I would expect something more like this for the top loop...

V1 - I1R1 - I2R2= 0

First step is always to mark the currents and their assumed direction. If you have done that post the diagram as it forms part of your working.
 
  • #3
Hi lee_sarah76. Welcome to Physics Forums.

A couple things. First, there are only four independent loops in the circuit for which you need write an equation. You only need as many loops as required so that at least one current passes through each component. So your fifth loop covers ground already tread by the four previous ones.

While adding the fifth loop doesn't appear to have affected MATLAB's ability to solve the system, it's more work for you, and strictly speaking it actually makes your equations wrong since you didn't account for I5 passing through components in the other equations.

Okay, that said, the results that MATLAB returned are fine! But they are MESH currents. To find the actual current through a given component you must sum the mesh currents that are running through it.

Here's your circuit for easy local reference:

attachment.php?attachmentid=62066&stc=1&d=1379890283.gif
 

Attachments

  • Fig1.gif
    Fig1.gif
    3.6 KB · Views: 595
  • #4
@CWatters: I guessed from the layout of the equations that lee_sarah76 was employing mesh analysis. If I'm wrong about that, I am happy to be corrected.
 
  • #5
Yes that makes more sense.
 
  • #6
Hi! Thank you both CWatters and gneill for answering. @CWatters: As gneill stated, I am attempting to employ mesh analysis, and the direction of the current is the same as gneill posted (Thank you for that!).

@gneill Thank you so much! I overlooked the fact that they were mesh currents when I got the answer and was simply puzzled. However, if you wouldn't mind, I am a little curious about the underlying physics and MATLAB software. You stated that my equations were wrong because I didn't account for I5 components going into the other equations, yet how did I get the right answer for the current through each mesh despite this? Was it simply pure luck? Just curious about this, as I see my mistake from before now!
 
  • #7
lee_sarah76 said:
Hi! Thank you both CWatters and gneill for answering. @CWatters: As gneill stated, I am attempting to employ mesh analysis, and the direction of the current is the same as gneill posted (Thank you for that!).

@gneill Thank you so much! I overlooked the fact that they were mesh currents when I got the answer and was simply puzzled. However, if you wouldn't mind, I am a little curious about the underlying physics and MATLAB software. You stated that my equations were wrong because I didn't account for I5 components going into the other equations, yet how did I get the right answer for the current through each mesh despite this? Was it simply pure luck? Just curious about this, as I see my mistake from before now!
It wasn't pure luck. When you tacked on the fifth equation it didn't affect any of the other equations; they still defined the operation of the circuit as given because you didn't include the current I5 in any of their definitions. In essence, the equation for the I5 loop constituted a separate circuit problem which was solved at the same time, in parallel with the problem you were trying to solve. Matrix methods can be very nifty that way. Two problems solved with one "run" of the program.
 

FAQ: How Do I Solve Kirchhoff's Loop Rule Problem in MATLAB?

1. What is Kirchhoff's Loop Rule?

Kirchhoff's Loop Rule, also known as Kirchhoff's Voltage Law, is a fundamental principle in circuit analysis that states that the sum of all voltages around a closed loop in a circuit is equal to zero.

2. When is Kirchhoff's Loop Rule used?

Kirchhoff's Loop Rule is used in circuit analysis to determine unknown voltages and currents in a circuit. It is also used to check the accuracy of circuit calculations and to troubleshoot circuit problems.

3. How is Kirchhoff's Loop Rule applied?

To apply Kirchhoff's Loop Rule, you must first identify all the closed loops in a circuit. Then, you write an equation for each loop by considering the direction and polarity of each voltage source and the direction of current flow through each resistor. Finally, you solve the resulting system of equations to find the unknown values.

4. What is the difference between Kirchhoff's Loop Rule and Kirchhoff's Junction Rule?

Kirchhoff's Junction Rule, also known as Kirchhoff's Current Law, states that the sum of all currents entering a junction in a circuit is equal to the sum of all currents leaving the junction. Kirchhoff's Loop Rule, on the other hand, deals with the voltages around a closed loop in a circuit.

5. Are there any exceptions to Kirchhoff's Loop Rule?

Kirchhoff's Loop Rule is a fundamental law of circuit analysis and is always valid in ideal circuits. However, in some cases, the rule may not apply due to the presence of non-ideal elements such as capacitors or inductors. In these cases, modified versions of the rule may be used.

Back
Top