MATLAB: Complex numbers in Symbolic Toolbox

imaginary partsymbolicSymbolic Math Toolbox

Seems, I don't understand the meaning of imag and real in Symbolic Toolbox.
Suppose the following syms a b c d, F=(a+j*b)/(c+j*d). imag(F) gives -1/2*i*((a+i*b)/(c+i*d)-conj((a+i*b)/(c+i*d)))
This is obviously true, but practically for no use; I would like to see the result as
(bc-ad)/(c^2+d^2)
Or, another and simpler example:
F=a+j*b, imF=imag(F) gives -1/2*i*(a+i*b-conj(a+i*b)); The expressions for real(F) or imag(F) may not contain imaginary unit i. The expected answer would be imF=b.
Do you know a solution?

Best Answer

[Updated]
Define the symbolic variables as real and use the function simplify when needed:
>> syms a b c d real;
>> F=a+j*b; G=c+j*d;
imF=imag(F)
imF =
b
>> D = F/G;
imag(D)
ans =
((a - b*i)*i)/(2*(c - d*i)) - ((a + b*i)*i)/(2*(c + d*i))
>> simplify(imag(D))
ans =
-(a*d - b*c)/(c^2 + d^2)