problem with imag command when evaluating symbolic expressions.
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi, when I execute the following code in Matlab
syms x y; f=4*i+9*x+y; imag(f)
I get the following result
ans =
(9*i*conj(x))/2 - (i*y)/2 - (9*i*x)/2 + (i*conj(y))/2 + 4
and the result should be 4 instead of what I get. I cannot figure out where have I gone wrong.Any ideas?
Thank you in advance.
댓글 수: 0
채택된 답변
Walter Roberson
2013년 2월 11일
The result is correct. The symbolic toolbox assumes that variables might be complex unless it has been told otherwise. Try
syms x y real
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Assumptions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!