Solve: System of symbolic linear equations
8 次查看(过去 30 天)
显示 更早的评论
Hello all,
Although this question has been asked before but I could not find a relevant answer to the problem.
I am trying to solve a system of linear equations but 'solve' does not give me a solution or it takes too long to find one.
clear all;close all;
syms v2 v3 v4 v5 v6 real positive
syms r4 r5 r6 r7 c4 c6 omega real positive
syms Av1 Av2 real positive
syms s %Laplace domain 's'. Cannot define as complex?
zc4=1/(s*c4)
zc6=1/(s*c6)
eqn1 = ((v3-v2)/r4) + ((v3-v4)/zc4) + ((v3-v6)/r5) == 0
eqn2 = ((v6-v3)/r5) + ((v6-v5)/zc6) + ((v6-v5)/r7) == 0
eqn3 = ((v4-v3)/zc4) + ((v4-v5)/r6) == 0
eqn4 = ((v5-v4)/r6) + ((v5-v6)/r7) + ((v5-v6)/zc6) == 0
eqn5 = v4 == -Av1*v3
eqn6 = v5 == -v6/Av2
eqns = [eqn1 eqn2 eqn3 eqn4 eqn5 eqn6];
vars = [ v3 v4 v5 v6 Av1 Av2 ];
S = solve(eqns,vars,'ReturnConditions',true,'Real',true)
v6_soln=S.v6
%vars= [ v3 v4 v5 ]
%S = eliminate(eqns,vars) % takes too long.
With syms defined as real and positive, solve does not find a solution. With syms defined as 'real' only solve takes too long to come to a solution, perhaps because it evaluates all possible solutions. I have also tried 'eiliminate' function. The system of equations will have multiple solutions if no conditions are assumed for syms. I'd like solve to return real solutions only.
Any help will be appreciated.
12 个评论
John D'Errico
2023-7-3
You have said that you want to solve for v6, in terms of v2.
The thing is solve is a computer program. Code sometimes is seemingly intelligent, yet usually is pretty stupid. That is definitely the case of solve.
syms v2 v3 v4 v5 v6 real positive
syms r4 r5 r6 r7 c4 c6 omega real positive
syms Av1 Av2 real positive
syms s %Laplace domain 's'
zc4=1/(s*c4);
zc6=1/(s*c6);
eqn1 = ((v3-v2)/r4) + ((v3-v4)/zc4) + ((v3-v6)/r5) == 0 ;
eqn2 = ((v6-v3)/r5) + ((v6-v5)/zc6) + ((v6-v5)/r7) == 0 ;
eqn3 = ((v4-v3)/zc4) + ((v4-v5)/r6) == 0 ;
eqn4 = ((v5-v4)/r6) + ((v5-v6)/r7) + ((v5-v6)/zc6) == 0 ;
eqn5 = v4 == -Av1*v3;
eqn6 = v5 == -v6/Av2;
The obvious is to eliminate v4 and v5. That part is simple, since we can those last two equations.
eqn1 = eliminate([eqn1,eqn5,eqn6],[v4,v5])
eqn2 = eliminate([eqn2,eqn5,eqn6],[v4,v5])
eqn3 = eliminate([eqn3,eqn5,eqn6],[v4,v5])
eqn4 = eliminate([eqn4,eqn5,eqn6],[v4,v5])
Next, isolate v6. What can we learn from that?
eqn1 = isolate(eqn1 == 0,v6)
eqn2 = isolate(eqn2 == 0,v6)
eqn3 = isolate(eqn3 == 0,v6)
eqn4 = isolate(eqn4 == 0,v6)
At least, what I see is something that is going to be difficult to now reduce the problem too much further. We want next to emininate the unknowns Av1, Av2, and v3, I think.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Equation Solving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!