필터 지우기
필터 지우기

Solve: System of symbolic linear equations

조회 수: 2 (최근 30일)
RAN
RAN 2023년 7월 3일
편집: RAN 2023년 7월 3일
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
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])
eqn1 = 
eqn2 = eliminate([eqn2,eqn5,eqn6],[v4,v5])
eqn2 = 
eqn3 = eliminate([eqn3,eqn5,eqn6],[v4,v5])
eqn3 = 
eqn4 = eliminate([eqn4,eqn5,eqn6],[v4,v5])
eqn4 = 
Next, isolate v6. What can we learn from that?
eqn1 = isolate(eqn1 == 0,v6)
eqn1 = 
eqn2 = isolate(eqn2 == 0,v6)
eqn2 = 
eqn3 = isolate(eqn3 == 0,v6)
eqn3 = 
eqn4 = isolate(eqn4 == 0,v6)
eqn4 = 
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.
RAN
RAN 2023년 7월 3일
편집: RAN 2023년 7월 3일
@John D'Errico Ok now I understand. I did end up finding a solution by substituting v4=-v3*Av1 and v5=-v6/Av2 in the first four eqns i.e eqn1,eqn2, eqn3, eqn4. Then I used 'solve' to solve for v3 and v6 but seperately. i.e [eqn1 eqn2],[eqn1 eqn3],[eqn1 eqn4] and the last combination gives me the correct solution. This also makes sense since eqn2 and eqn3 are redundant. But I was hoping that 'solve' function gives me four solutions for me to choose from instead of solving them in steps.
@Torsten The structure of the problem i have formulated is wrong. Yes I would need one equation less.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by