Use "Solve" function to find certain value of magnitude of complex function
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Walter Roberson
il 11 Dic 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 Commenti
Walter Roberson
il 19 Dic 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))
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!