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!