solving a nonlinear equation with complex numbers
5 次查看(过去 30 天)
显示 更早的评论
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
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))
disp(char(X1))
0 个评论
更多回答(2 个)
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])
%sol = solve(eqn,[R,X],'ReturnConditions',true)
0 个评论
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)
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])
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.)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
