equationsToMatrix and linsolve giving incorrect results for voltage divider

9 views (last 30 days)
I need the solutions for r1, r2 and r3 for the following voltage divider:
Hence the following eqs. system arise:
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
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]
and
Y=[12.5e3, 21.3e3, 23.8e3]
Then linsolve(A,Y) gives:
ans =
1.0e+04 *
0.2084
0.6390
2.2760
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!!

Accepted Answer

John D'Errico
John D'Errico on 23 Oct 2016
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)
A =
[ 381/500, 381/500, 381/500]
[ -213/1000, 787/1000, 787/1000]
[ -1/8, -1/8, 7/8]
b =
23800
21300
12500
... 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.

More Answers (1)

Tfm tfm
Tfm tfm on 23 Oct 2016
John,
Thank you for your time. That is right, I got sloppy on the hand calculations and didn't notice it before.
Best regards.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!