complex numbers in Symbolic Toolbox

41 Ansichten (letzte 30 Tage)
Juraj
Juraj am 1 Sep. 2011
Kommentiert: Walter Roberson am 3 Nov. 2017
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?
  1 Kommentar
Walter Roberson
Walter Roberson am 1 Sep. 2011
Opps! I deleted some of the text while reformatting. I have notified Juraj.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Lucas García
Lucas García am 1 Sep. 2011
[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)
  5 Kommentare
Walter Roberson
Walter Roberson am 2 Sep. 2011
Also sometimes it helps to expand() and then simplify() again.
When working with imaginary values in Maple, sometimes I find I can make significant simplifications by simplify(combine(convert(EXPRESSION,expln))) and then converting back to real + i*imaginary format. Unfortunately I have not managed to find the MuPad equivalents of Maple's convert() or combine() functions.
Walter Roberson
Walter Roberson am 3 Nov. 2017
From R2012a, rewrite() can be used to do some conversions; from R2014a, combine() can be used to combine operations.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Modess Seyednezhad
Modess Seyednezhad am 3 Nov. 2017
But I got this:
>> syms a b c d real; F=a+j*b; G=c+j*d; imF=imag(F)
imF =
b
>> D = F/G; >> k=imag(D)
k =
(b*c)/(c^2 + d^2) - (a*d)/(c^2 + d^2)
????
  1 Kommentar
Steven Lord
Steven Lord am 3 Nov. 2017
And that expression for k is equivalent to the expression Juraj expected. Either simplify k or use numden to extract the numerator and denominator of k and it should match your expectation.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by