How to solve a symbolic complex equation with real and imaginary parts?
27 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nélio Dias
am 6 Apr. 2021
Kommentiert: Nélio Dias
am 7 Apr. 2021
I have to solve this polynomium:
to
. So, I know that to solve this equation I have to replace the s to get
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/574967/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/574972/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/574977/image.png)
Therefore, the real and imaginary parts will be zero and we have
and ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/574987/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/574982/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/574987/image.png)
So, to solve this in matlab, I write this code:
syms s k w
den = s^3 + 9*s^2 + 14*s + 126
assume([ k> 0,w >0])
solw = solve(imag(den)==0, w)
den = subs(den, w, solw)
solk = solve(den==0, k)
Then, this code work well, but if I change the polynomial degree I will have to change the parameters of solve function. So I to know if there is a more generic way to solve this equations
Thanks for reading
0 Kommentare
Akzeptierte Antwort
Paul
am 7 Apr. 2021
I'm not sure what "change the paramters of the solve function" means. If a general apprach is desired, maybe something along the lines of simultaneously solving two equations for two unkonwns:
>> syms s w k
assume(w>=0); assume(k>=0);
D(s) = s^3 + 9*s^2 + 14*s + 2*k;
eqn = [real(D(1j*w))==0, imag(D(1j*w))==0];
sol = solve(eqn,[w k],'ReturnConditions',true);
[sol.w sol.k]
ans =
[ 0, 0]
[ 14^(1/2), 63]
Change D(s) as desired.
3 Kommentare
Walter Roberson
am 7 Apr. 2021
If your polynomial degree is 3 or higher, there is a risk that solve() will decide to return root() objects instead of explicit solutions. You can reduce that problem by using
sol = solve(eqn,[w k],'ReturnConditions',true, 'maxdegree', 4);
which tells it to use explicit formulas up to degree 4.
However, with large enough polynomial degree, solve() will not be able to find an explicit solution, and you will start seeing root() constructs. You can vpa() to get numeric equivalents.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Calculus finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!