Solve a group of Symbolic Equations

조회 수: 5 (최근 30일)
Matthew Worker
Matthew Worker 2023년 2월 25일
편집: Dyuman Joshi 2023년 2월 25일
syms A B alpha beta % variable
syms R1 R2 C1 C2 % constant
eqn1 = A + B == 1/(R1*C1)
eqn1 = 
eqn2 = -A*beta-B*alpha == 0
eqn2 = 
eqn3 = alpha*beta == 1/(R1*C1*R2*C2)
eqn3 = 
eqn4 = (R1*C1+R1*C2+R2*C2)/(R1*C1*R2*C2) == -alpha-beta
eqn4 = 
[A,B,alpha,beta] = solve(eqn1,eqn2,eqn3,eqn4)
A = 
B = 
alpha = 
beta = 
A1 = simplify(A)
A1 = 
B1 = simplify(B)
B1 = 
alpha1 = simplify(alpha)
alpha1 = 
beta1 = simplify(beta)
beta1 = 
I want to get A1,B1,alpha1,beta1 represented only by constant (R1 R2 C1 C2). However, when I run the codes, the system gives me:
A1 =
1/(C1*(A + B))
1/(C1*(A + B))
B1 =
-(A^2*C1 + B^2*C1 - A*(C1*(A^2*C1 + B^2*C1 + 2*A*B*C1 + 4*A*B*C2))^(1/2) + B*(C1*(A^2*C1 + B^2*C1 + 2*A*B*C1 + 4*A*B*C2))^(1/2) + 2*A*B*C2)/(2*A*B*C1*C2*(A + B))
-(A^2*C1 + B^2*C1 + A*(C1*(A^2*C1 + B^2*C1 + 2*A*B*C1 + 4*A*B*C2))^(1/2) - B*(C1*(A^2*C1 + B^2*C1 + 2*A*B*C1 + 4*A*B*C2))^(1/2) + 2*A*B*C2)/(2*A*B*C1*C2*(A + B))
alpha1 =
((A + B)*((C1*(A^2*C1 + B^2*C1 + 2*A*B*C1 + 4*A*B*C2))^(1/2) + A*C1 - B*C1))/(2*B*(C1 + C2))
-((A + B)*((C1*(A^2*C1 + B^2*C1 + 2*A*B*C1 + 4*A*B*C2))^(1/2) - A*C1 + B*C1))/(2*B*(C1 + C2))
beta1 =
-((A + B)*((C1*(A^2*C1 + B^2*C1 + 2*A*B*C1 + 4*A*B*C2))^(1/2) + A*C1 - B*C1))/(2*A*(C1 + C2))
((A + B)*((C1*(A^2*C1 + B^2*C1 + 2*A*B*C1 + 4*A*B*C2))^(1/2) - A*C1 + B*C1))/(2*A*(C1 + C2))
What other codes should I add to solve this problem?

채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 2월 25일
편집: Dyuman Joshi 2023년 2월 25일
You need to specify which variables are you solving for -
syms A B alpha beta % variable
syms R1 R2 C1 C2 % constant
eqn1 = A + B == 1/(R1*C1);
eqn2 = -A*beta-B*alpha == 0;
eqn3 = alpha*beta == 1/(R1*C1*R2*C2);
eqn4 = (R1*C1+R1*C2+R2*C2)/(R1*C1*R2*C2) == -alpha-beta;
[A0,B0,alpha0,beta0] = solve([eqn1,eqn2,eqn3,eqn4],[A, B, alpha, beta]);
A0
A0 = 
B0
B0 = 
alpha0
alpha0 = 
beta0
beta0 = 

추가 답변 (1개)

Walter Roberson
Walter Roberson 2023년 2월 25일
You have four equations in 8 unknowns. When you call solve() you should specify the names of the variables to solve for. solve() is not able to read the names of the variables you are assigning to in order to figure out which variables you want to solve for.

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by