complex numbers in Symbolic Toolbox

조회 수: 222(최근 30일)
Juraj 2011년 9월 1일
댓글: Walter Roberson 2017년 11월 3일
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
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
Walter Roberson
Walter Roberson 2011년 9월 1일
Opps! I deleted some of the text while reformatting. I have notified Juraj.

댓글을 달려면 로그인하십시오.

채택된 답변

Lucas García
Lucas García 2011년 9월 1일
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 =
>> D = F/G;
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
Walter Roberson
Walter Roberson 2017년 11월 3일
From R2012a, rewrite() can be used to do some conversions; from R2014a, combine() can be used to combine operations.

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Modess Seyednezhad
Modess Seyednezhad 2017년 11월 3일
But I got this:
>> syms a b c d real; F=a+j*b; G=c+j*d; imF=imag(F)
imF =
>> D = F/G; >> k=imag(D)
k =
(b*c)/(c^2 + d^2) - (a*d)/(c^2 + d^2)
  댓글 수: 1
Steven Lord
Steven Lord 2017년 11월 3일
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.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by