equationsToMatrix and linsolve giving incorrect results for voltage divider
조회 수: 29(최근 30일)
I need the solutions for r1, r2 and r3 for the following voltage divider:
Hence the following eqs. system arise:
1) [A,B] = equationsToMatrix([eq1,eq2,eq3], [r1,r2,r3]) gives the error: "Cannot convert to matrix form because the system does not seem to be linear." It seems linear to me, what am I missing?
2) I made step 1 by hand, and found A*X=Y leading to:
A = [-.875 -.875 .875, -.787 .787 .787, .762 .762 .762]
X=[r1, r2, r3]
Y=[12.5e3, 21.3e3, 23.8e3]
Then linsolve(A,Y) gives:
However this answer is wrong. If I enter these values in a simulation, I don't get, i.e., 0.125*Vs over R3. What am I missing again??
3) I found the correct answer using solve instead of linsolve:
[x1, x2, x3]=solve(eq1,eq2,eq3)
Gives after vpa():
x1 = 3281
x2 = 115448
x3 = 16404
And those values run fine during simulation. I still don't get 1) and 2) though.
- Also seems like hitting enter while typing won't space between lines!!
John D'Errico 2016년 10월 23일
Is this a linear equation in x and y?
x/y = a
NO. It is not. Perhaps you think you can transform it to a linear equation, simply by multiplying by y, to yield
x = y*a
NOT true. The two equations simply are not the same, because if y=0, that implies x=0 in the latter case, whereas (x,y) = (0,0) is NOT a valid solution to the original equation.
So MATLAB told you those equations are not in fact linear, which is the fact.
Now, suppose we decide that (1e5 + r1 + r2 + r3) will NEVER be zero.
syms r1 r2 r3
eq1=(r1+r2+r3) == (1e5+r1+r2+r3)*0.238;
eq2=(r2+r3) == (1e5+r1+r2+r3)*0.213;
eq3=(r3) == (1e5+r1+r2+r3)*0.125;
[A,b] = equationsToMatrix(eq1,eq2,eq3)
[ 381/500, 381/500, 381/500]
[ -213/1000, 787/1000, 787/1000]
[ -1/8, -1/8, 7/8]
... which is not what you wrote. So you need to check your algebra. And you need to remember what they surely taught you some years ago in algebra 1 about the dangers of multiplying by zero.