Finding the magnitude and phase of a variable in a complex equation in terms of variables only

5 visualizzazioni (ultimi 30 giorni)
I would like to solve the following equation for the magnitude and phase of vo
vo = vi * ( r / ( r + (1/j*w*c)))
The problem is, I do not know how to specify that r, w and c have only real parts while vi is a complex number with a magnitude of vi and a phase of phi.
I have tried using real(r), real(w) etc. in the calculations however the calculation of the magnitude using abs() does not give me the desired answer.
>>syms vo vi r w c //FIRST METHOD//
>>vo=vi*(r/(r+(1/(j*w*c))))
vo =
(r*vi)/(r - 1i/(c*w))
>>abs(vo)
ans =
abs(r*vi)/abs(r - 1i/(c*w)) <--- magnitude contains imaginary number which i would like to be removed (included in the calculation)
>>syms vo vi r w c //SECOND METHOD//
>>vo = vi * real (r) / ( real(r) + 1/(j*real(c)*real(w)))
vo =
(vi*real(r))/(real(r) - 1i/(real(c)*real(w)))
>>abs(vo)
ans =
abs(vi*real(r))/abs(real(r) - 1i/(real(c)*real(w)))
Note that I would like to obtain the following expression: Assuming that vim is the magnitude of vi
abs(vo) = vim / ( 1+(1/r*w*c)^2)^(1/2)
angle(vo) = phi + atan2d(1/r*w*c)

Risposta accettata

Star Strider
Star Strider il 26 Nov 2017
I cannot follow everything you are doing. For some reason, abs is not computing the magnitude of the complex function.
I was able to get this to work:
syms vo vi r w c % //FIRST METHOD//
vo=vi*(r/(r+(1/(1j*w*c))));
vo_mag = vo * conj(vo);
vo_mag = simplify(vo_mag)
vo_phs = atan(imag(vo)/real(vo))
vo_mag =
(c^2*r^2*vi^2*w^2)/(c^2*r^2*w^2 + 1)
vo_phs =
atan(1/(c*r*w))
Note that atan2 is not defined for symbolic expressions.
  4 Commenti
Tiger Schad
Tiger Schad il 26 Nov 2017
I am using R2017b aswell. What worked for me was using :
assume(r, 'positive')
assumeAlso(r, 'real') //I did this for vi w c and r
Thank you again for your help
However, I only get the solution if I assume vi to be real and positive. Vi could be a complex number and I would like to know how do I tell matlab that Vi has a magnitude of say vi_mag and an angle of vi_phs ( in polar form).
Star Strider
Star Strider il 26 Nov 2017
My pleasure.
I experimented with this problem a bit more. My results are the same as I posted them.
I did not need to specify ‘Vi’ to be real and positive to get the result I posted, and I specifically did not because you specified it as complex. It may inherit those assumptions from the assumptions on the other variables, although it should not. I cannot reproduce the problems you are seeing (my code as posted produces the results I posted), so I cannot suggest a solution.
Since I assume ‘c’ and ‘r’ are real and positive (the atan or atan2 argument takes the sign of ‘w’), the phase will be between and 180°, so you can use atan. So for positive ‘w’, the phase will be between and +90°.

Accedi per commentare.

Più risposte (0)

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by