Symbolic solve not returning all values

Hello everyone! I am new to MATLAB, and I am trying to use it to solve for some variables in a system of equations (this is for the node-voltage equations of a filter, but that isn't fully relevant)
syms Va Vi Vhp Vlp Vbp R2 R3 R1 Rf R s C RH RB RL RF Vo
eqn0 = (( (Va-Vi)/R2) + ( (Va-Vbp)/R3) )== 0;
eqn1 = ( ((Va-Vlp)/R1) + ( (Va-Vhp)/Rf) )==0 ;
eqn2 = (-(Vhp/R) -(Vbp*s*C))==0;
eqn3 = (-(Vbp/R) - (Vlp*s*C))==0;
eqn4 = (-Vhp/RH -Vbp/RB -Vlp/RL - Vo/RF==0);
S = solve(eqn1, eqn2, eqn3, eqn0, eqn4)
Va, Vi, Vhp, Vlp, Vbp, and Vo are all "unknowns", while the rest are supposed to be treated as constants. Ideally, I want it to solve for H(s) = (Vo/Vi) .. Or really, I'd prefer to just be able to find out what every term rearranges to (i.e solving for Vbp, Vhp, Vlp, in terms of the other ones).
But when I run "solve", I get as follows.
Va: [2×1 sym]
Vbp: [2×1 sym]
Vhp: [2×1 sym]
Vi: [2×1 sym]
s: [2×1 sym]
Within these solutions are two (? why? is it not linear?.. Im not sure..) different expressions.
% For S.Vbp
ans =
-(Vlp*(RH - (-(RH*(4*RB^2*RF*Vlp + 4*RB^2*RL*Vo - RF*RH*RL*Vlp))/(RF*RL*Vlp))^(1/2)))/(2*RB)
-(Vlp*(RH + (-(RH*(4*RB^2*RF*Vlp + 4*RB^2*RL*Vo - RF*RH*RL*Vlp))/(RF*RL*Vlp))^(1/2)))/(2*RB)
%Besides the fact there's *two* equations, this is what I want: just a big
%list of rearranged variables. But again: why two equations!
I am new to MATLAB and I do not really have a concept of the nature of linear equations (I haven't taken linear algebra) besides "you need one for every variable you want to find", so I do not know where this issue may be coming from. Is it because all the other "variables" (constants) are being treated as variables and there aren't enough equations? I've checked my equations with two friends and I am confident there's nothing wrong with them.
Thanks!

1 Kommentar

Paul
Paul am 11 Apr. 2026 um 3:10
Hi Sebastian,
Check the doc page for solve. The system of eqns is specified as single input argument. And the variables to solve for should be specified as the second input argument (unless you want solve to choose them for you, which is not what you want in this case, and it's always clearer to specify them explicitly anyway). So the solve command should be somethng like
S = solve([solve(eqn1, eqn2, eqn3, eqn0, eqn4)],[Va, Vi, Vhp, Vlp, Vbp, Vo ])
However, there's only five equations with six unknowns, and there is no solution (other than a trivial solution with all of the unknowns zero). Is there a missing equation? Or is one of the unknowns not really unknown?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Star Strider
Star Strider am 11 Apr. 2026 um 3:27
There are two equations because they are the roots to a quadratic equation.
sympref('AbbreviateOutput',false);
syms Va Vi Vhp Vlp Vbp R2 R3 R1 Rf R s C RH RB RL RF Vo
eqn0 = (( (Va-Vi)/R2) + ( (Va-Vbp)/R3) )==0;
eqn1 = ( ((Va-Vlp)/R1) + ( (Va-Vhp)/Rf) )==0;
eqn2 = (-(Vhp/R) -(Vbp*s*C))==0;
eqn3 = (-(Vbp/R) - (Vlp*s*C))==0;
eqn4 = (-Vhp/RH -Vbp/RB -Vlp/RL - Vo/RF)==0;
S = solve(eqn1, eqn2, eqn3, eqn0, eqn4)
S = struct with fields:
Va: [2×1 sym] Vbp: [2×1 sym] Vhp: [2×1 sym] Vi: [2×1 sym] s: [2×1 sym]
SVbp = S.Vbp
SVbp = 
SVa = S.Va
SVa = 
SVhp = S.Vhp
SVhp = 
SVi = S.Vi
SVi = 
Ss = S.s
Ss = 
There may be something missing here. When I write node-voltage branch equations, I write the individual branch equations and then sum them at the nodes, and then solve the nodes. That may be the reason I am finding it difficult to determine values for and here, in terms of the other components. That should be possible.
Then, solve for and divide it by to get an expression for the transfer function. You should get a polynomial equation in powers of s.
It's always good to know linear algebra, however that is not strictly necessary for this problem.
.

2 Kommentare

Sebastian
Sebastian am 11 Apr. 2026 um 5:27
Verschoben: Stephen23 am 11 Apr. 2026 um 6:12
@Paul @Star Strider Firstly, thank you both for being so kind in the replies. I was worried I'd get chewed out as my question was relatively simple .
@Paul Thank you for showing me how to do it like that. It actually worked perfectly when I did this:
S = solve([eqn1, eqn2, eqn3, eqn0, eqn4],[Vhp, Vlp, Vbp, Vo, Vi])
(Leaving this here as the code you sent had an extra "solve" term. Not trying to correct you, I just know when I browse/skim forums for solutions I usually don't catch things like that.. so it's for future viewers :) )
And yes, one of the unknowns isn't actually unknown! I totally forgot I did not need to solve for Va, as it cancels out (and is not used in other calculations). Now I can do system of equations on Matlab!
@Star Strider Yeah.. the double solutions were definitely a sign of something wrong. I redid node voltage on a really simple op-amp example and I realized when doing NV (for op-amps, at least), you dont use the node at the input terminal in your final equations (as it cancels out) For me, this was the "Va" term that I did not actually need to solve for. Tangent: do you think linear algebra is important for EE? I heard it comes up everywhere.
Thank you both again guys. I was really stressed about this, and I kept sinking time to no avail. Have a great weekend.
Stephen23
Stephen23 am 11 Apr. 2026 um 6:13
@Sebastian: please don't forget to accept the answer that best resolve your original question.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Version

R2025b

Tags

Gefragt:

am 11 Apr. 2026 um 2:49

Kommentiert:

am 11 Apr. 2026 um 6:13

Community Treasure Hunt

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

Start Hunting!

Translated by