Engineering Linear Algebra - Analysis of purely resistive DC circuit

Click For Summary
The discussion revolves around troubleshooting a purely resistive DC circuit using linear algebra and MATLAB. The user encountered a warning about a singular matrix when attempting to solve the circuit equations, indicating potential issues with the circuit's configuration. Suggestions included adding a ground to node 7 to provide a return path for current and debugging the circuit by disabling power sources. After implementing a ground at node 6, the simulation ran successfully, but the user remained confused about the persistent singular matrix error in MATLAB. The conversation emphasizes the importance of ensuring a closed circuit for current flow and how circuit topology affects the equations used in simulations.
  • #31
You started this thread with a voltage source and two current sources. Now you have "updated" it by removing one current source, apparently. Is the circuit now as you desire it?
 
Physics news on Phys.org
  • #32
Yeah it is and it's runniung in my simulator, my only concern is MATLAB is not providing me an answer. I seem to be struggling more so with the linear algebra part now. I'm not exactly sure what I'm doing wrong =(. Thanks for any help.
 
  • #33
I don't think the problem is with the linear algebra. Your problem seems to be in deriving the correct equations that correspond to this circuit. The fact that you can change the circuit and yet not change the equations should be a giant red flag to you that your method is wrong.

Look at what you wrote here:
View attachment 99235
How can it possibly be correct? You have a six-component vector set equal to a seven-component vector.

Can you define for us what the x's and y's stand for? From a dimensional analysis point of view, something is amiss. It looks like the y's are voltages, yet you're multiplying them by R and getting currents. That is, your version of Ohm's law is I=VR.
 
  • #34
Yea your right about that. Thanks for catching that. It's a typo. It's supposed to be:
upload_2016-4-17_16-21-57.png

That does seem to be problematic. But I'm not exactly sure what would change in the equations. The incidence matrix N and six columns and six rows. The first column represents node 1, the second column represents node 2, and so forth. Row 1 represents edge 1, row 2 represents edge 2, and so forth. I populate the incidence matrix N by looking at each edge and if crrent is leaving the node I put a negative one, and if it's entering the node I put a positive one.
upload_2016-4-17_16-25-30.png

The vector V is the voltage across each resistor. At least this is how I was taught but to me it looks like the opposite of the voltage drop. Like I have the following
X_2 - X_1 = V_1 when in my opinion X_1 - X_2 = V_1. But this is how we were taught, not sure if it's wrong?

The resistance matrix R is just a diagonal matrix, where column one row one represents R_1, column 2 row 2 represents R_2 and so forth.
upload_2016-4-17_16-35-13.png

HW solutions solved a similar problem in a similar way but the final calculation was never done. My textbook doesn't seem to have a resistive circuit example.

Yeah
X_1 = nodal voltage at node 1
X_2 = nodal voltage at node 2
X_3 = nodal voltage at node 3
.
.
.

Y_1 = current going across edge 1 (R_1)
Y_2 = current going across edge 2 (R_2)
.
.
.

Also C^(-1) = R
so I use the following relation
The matrix I represents the applied currents to the circuit. Since I only have one current source at node 4 I get the following
upload_2016-4-17_16-34-8.png

looks like I had it wrong before by accident.
The matrix E represents the applied voltage sources in the circuit which is only at node 6 so E is
upload_2016-4-17_16-34-50.png


upload_2016-4-17_16-32-5.png

I try re-entering this into MATLAB and create the zero matrix A to help.
>> N=[-1 1 0 0 0 0;0 -1 0 1 0 0;-1 0 1 0 0 0;0 0 1 -1 0 0;0 0 -1 0 1 0;0 0 0 0 -1 1]

N =

-1 1 0 0 0 0
0 -1 0 1 0 0
-1 0 1 0 0 0
0 0 1 -1 0 0
0 0 -1 0 1 0
0 0 0 0 -1 1

>> R=[1 0 0 0 0 0;0 2 0 0 0 0;0 0 3 0 0 0;0 0 0 4 0 0;0 0 0 0 5 0;0 0 0 0 0 6]

R =

1 0 0 0 0 0
0 2 0 0 0 0
0 0 3 0 0 0
0 0 0 4 0 0
0 0 0 0 5 0
0 0 0 0 0 6

>> I=[0;0;0;2;0;0]

I =

0
0
0
2
0
0

>> E=[0;0;0;0;0;5]

E =

0
0
0
0
0
5

>> A=[0 0 0 0 0 0;0 0 0 0 0 0;0 0 0 0 0 0;0 0 0 0 0 0;0 0 0 0 0 0;0 0 0 0 0 0]

A =

0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0

>> inv([R N;N' A])*[I;E]
Warning: Matrix is close to singular or badly
scaled. Results may be inaccurate. RCOND =
2.312965e-18. ans =

1.0e+16 *

0.0000
0.0000
-0.0000
0.0000
0.0000
0.0000
4.5036
4.5036
4.5036
4.5036
4.5036
4.5036

to solve for the matrix [y;x]. The problem is that when I plug this into MATLAB I get the error and I don't why =(. Thanks for any help.
 
  • #35
YoshiMoshi said:
The incidence matrix N remains the same. Right?
Isn't that thing that uses the
GND.png
symbol a node that should be included? After all, it's purpose is to carry current.
 
  • #36
Yeah it's node 6 in my calculations and there in incidence matrix N. But for E right is node 6 supposed to be 0 or 5? I thought 5. Am I wrong? Is node supposed to be 5 in the vector E instead? I don't understand how it changes N
 
  • #37
Don't the sources, both voltage and current, need to specify the nodes they are between, i.e. what edge number applies to them?

BTW, just for future reference, usually the Ground node is labelled as Node 0. Easier to keep track of that way. I'm NOT suggesting you change the node numbering in this problem though. Way too late for that!
 
  • #38
So I'm not exactly sure what do I change in the equations to indicate this?

Thanks for ur help!
 
  • #39
I haven't used MATLAB so this may be too simplistic. Create an edge for each of the sources and a way to indicate that they are sources rather than resistors.
 
  • #40
I don't see how to do that in MATLAB? I don't think u can. Like what do I change in the matrix exactly to indicate this? I'm not sure thanks for ur help
 
  • #41
Don't know. Never tried authoring a simulator.
Hopefully someone here has some ideas.
 
  • #42
Yeah I'm using MATLAB to performing the matrix calculation. I think that the problem is defiantly this
inv([R N;N' A])
MATLAB is telling me that the matrix is singular. I defiantly think that R is ok. So N must be wrong, but I don't necessairly see how.

I see possibly that node 6 is connected to ground, which also connected to a two ampere power source which is connected to node 4. Do I need to include this in my incidence matrix? Do I have to call the current source an edge 7 and extend my R matrix to have the seventh row and seventh column be 0 since an ideal current source has zero resistance. Like I'm wondering if I need to update the matrix N to a 7 x 6 matrix were current is leaving node 6 and entering node 4?

Let me know if you don't know what I'm talking about.

I don't think it works. I just tried, N would be a 7x6 matrix, R would be a 7x7 matrix, N' would be a 6x7 matrix, and the zero matrix would be 7x7. MATLAB wouldn't allow an inverse matrix on such a matrix.
 
Last edited:
  • #43
BUMP went onto second page still not solved yet. Thanks for any help. I think that it may have to do with the problem being nearly singular, the determinant is not zero but very close to zero, so when I try to take the inverse it throws the error providing me with the incorrect result. Is there any way I can get MATLAB to give me the correct answer?
 
  • #44
Let me ask this, is there a way to change the problem so that way I don't have this issue of the matrix being near singular causing MATLAB to throw an error?
 
  • #45
BUMP
no answer yet
 
  • #46
You need to resolve the issues as pointed out in posts #4 and #11.

Those issues indicate that the circuit you have drawn does not correspond to a real circuit, or that the real circuit has been misinterpreted when transcribing the schematic.
 
  • #47
I thought i did though in number 34? What other changes do I still need to make exactly? Sorry I'm not sure.
 
  • #48
YoshiMoshi said:
I thought i did though in number 34? What other changes do I still need to make exactly? Sorry I'm not sure.

I'm not sure either as the method of circuit analysis that you're using is not one I use. But I did note that I don't see where the 2 A current source fits in with your incidence matrix. Shouldn't it have an "edge"? It moves current from node 6 to node 4.
 
  • #49
Ya I normally don't do it this way either. But yah I put it in matrix I.

I believe my solution is correct in #34 it's just giving me the error because the determinant of the matrix is nearly zero, so when MATLAB takes the inverse of the matrix it throws an error saying that it's signular or nearly singular and that the calculation may be incorrect, which the answer MATLAB provided doesn't match with my simulated answer.

That's why I put it in the MATH section because I think I'm more strugling with the linear algebra method of solving this problem and not so much the engineering aspects of it, but it got moved here.

I think this is now a linear algebra problem and think that MATLAB is giving the wrong answer becuase it's nearlly singular. I'm almost positive because that's what MATLAB says and sure enough the determinant is nearly zero, and when the determinant is zero the matrix cannot be inverted. I can still invert it though becuase it's not exactly zero but close to it. So I'm just wondering what I can change so that this is no longer the case. But a 12x12 matrix is kind of hard to work with and I'm not exactly sure which numbers should get changed.
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 7 ·
Replies
7
Views
5K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 24 ·
Replies
24
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K