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

complex expressioncomplex numbersdeclaring complex variablesMATLABsimplifying complex expressionvariables

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)

Best Answer

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.