Use "Solve" function to find certain value of magnitude of complex function
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a function with complex variable. I want to get the value of "s" at which the magnitude of the function equals certain value (e.g. 10).
I use "abs" to get the magnitude of the function, then use "solve". If I get the magnitude by using sqrt(real^2+imag^2) I et different answer (actually the one that I need).
However, when I plot both magnitudes, the results are the same.
Code is here:
syms s;
y = 10/((j*s)^2+(j*s)+1);
mag_sqrt = sqrt((real(y))^2+(imag(y))^2);
mag_abs = abs(y);
solve_abs = double(solve(20*log10(mag_abs)==10)) % answer = 0.0000 + 2.0532i , 0.0000 - 1.0532i (wrong answer)
solve_sqrt = double(solve(20*log10(mag_sqrt)==10)) % answer = 1.8819, -1.8819 (Correct answer)
ezplot(20*log10(mag_sqrt),0.1,100); grid on;
ezplot(20*log10(mag_abs),0.1,100); grid on;
phase = (180/pi)*double(subs(angle(y),s,solve_abs)) % answer = 0 (Wrong answer)
phase = (180/pi)*double(subs(angle(y),s,solve_sqrt)) % answer = -143.4806 , 143.4806 (Correct answer)
0 Kommentare
Antworten (1)
Walter Roberson
am 11 Dez. 2016
syms s real
When you ask solve to solve a non-polynomial with multiple roots then it will return either a parameterized solution or else it will solve numerically. You did not constrain the range of values so it happened to decide to pick an imaginary valued solution. Forcing real values has a better chance of getting one of the two values you are expecting.
2 Kommentare
Walter Roberson
am 19 Dez. 2016
syms s real
y = 10/((j*s)^2+(j*s)+1);
mag_sqrt = simplify(sqrt((real(y))^2+(imag(y))^2), 'steps', 20)
double(solve(20*log10(mag_sqrt)==10))
Siehe auch
Kategorien
Mehr zu Conversion Between Symbolic and Numeric 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!