solving a nonlinear equation with complex numbers

조회 수: 5 (최근 30일)
Mimo T
Mimo T 2024년 11월 7일
편집: Paul 2024년 11월 7일
I want to get the values of resistance and reactance of a parallal impedance that gives me specific value for magnitude and phase of the reflection coefficient. Resistance must be positive only while X must be a real number. This is my code
syms R
syms X
Z=(R*1i*X/(R+1i*X));
r=(Z-Zo)/(Z+Zo);
assume(R,'positive')
assume(X,'real')
eqn=[abs(r)==0.5, angle(r)==55*pi/180];
[R1,X1]=vpasolve(eqn,[R,X])
I can not add these constains like solve function and sometimes R becomes negative. (solve function can't be used here because it gives me a warning that vpasolve is used).
Trying to add R>0 in cases vpasolve gives positive R, leads to empty solution.
  댓글 수: 2
Walter Roberson
Walter Roberson 2024년 11월 7일
Unfortunately your code does not define Zo.
Mimo T
Mimo T 2024년 11월 7일
Yes, I missed it when I copied the code.
Zo=50;

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

채택된 답변

Walter Roberson
Walter Roberson 2024년 11월 7일
편집: Walter Roberson 2024년 11월 7일
Zo = 50;
syms R
syms X
Z=(R*1i*X/(R+1i*X));
r=(Z-Zo)/(Z+Zo);
assume(R,'positive')
assume(X,'real')
eqn=[abs(r)==0.5, angle(r)==55*pi/180];
[R1,X1]=vpasolve(eqn,[R,X], [0 inf; -inf inf]);
disp(char(R1))
121.57176242340307307386879418841
disp(char(X1))
111.30878870807649324383788998856

추가 답변 (2개)

Paul
Paul 2024년 11월 7일
편집: Paul 2024년 11월 7일
Does this solution work?
syms R
syms X
Zo = sym(50);
Z=(R*1i*X/(R+1i*X));
r=(Z-Zo)/(Z+Zo);
assume(R,'positive')
assume(X,'real')
eqn=[abs(r)==0.5, angle(r)==55*pi/180];
[R1,X1]=vpasolve(eqn,[R,X],[0,inf;-inf,inf]) % specify initial search bounds
double([R1,X1])
ans = 1×2
121.5718 111.3088
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
%sol = solve(eqn,[R,X],'ReturnConditions',true)

John D'Errico
John D'Errico 2024년 11월 7일
편집: John D'Errico 2024년 11월 7일
syms R positive % positive implicitly implies real also
syms X real
syms Zo
Z=(R*1i*X/(R+1i*X));
r=(Z-Zo)/(Z+Zo)
r = simplify(r)
Suppose we knew the value of Zo? I'll pick 0.5 as an example.
r_Zo = subs(r,Zo,0.5)
eqn = [abs(r_Zo)==0.5, angle(r_Zo)==55*pi/180]
Now, can we solve this?
RX = solve(eqn,[R,X],returnconditions = true)
RX = struct with fields:
R: z1 X: z2 parameters: [z1 z2] conditions: abs((z1*1i)/2 - z2/2 + z1*z2)/abs(z2/2 - (z1*1i)/2 + z1*z2) - 1/2 == 0 & - (11*pi)/36 + angle(((z1*1i)/2 - z2/2 + z1*z2)/(z2/2 - (z1*1i)/2 + z1*z2)) == 0 & 0 < z1
Essentially, solve is telling us it cannot find an algebraic form for the solution. However, as long as Zo is known, we can use a numerical tool like vpasolve.
RX = vpasolve(eqn,[R,X])
RX = struct with fields:
R: 1.2157176242340307307386879418841 X: 1.1130878870807649324383788998856
The problem is, if Zo is left unknown, then there will be no analytical solution for the problem. You cannot use solve, as I just showed, and vpasolve cannot be employed to solve problems with unknown symbolic dependencies.
(Sadly, Answers is bugged, and it is not showing the symbolic output. One year they will fix this, what was working nicely only a month or so ago, and what does OCCASIONALLY work to this day. SIGH.)
  댓글 수: 2
Mimo T
Mimo T 2024년 11월 7일
but vpasolve returns R with a negative value. This is my question that vpasolve doesn't take into account the conditions
Mimo T
Mimo T 2024년 11월 7일
I am also sure that there is an admittance (which is Z) on smith chart with positive value of R that is the solution

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

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by