Complex number when using variables
显示 更早的评论
I am getting two different answers in MATAB 2017a. If I compute it directly in the Command Window vs assigning the variables x,y, I get a complex answer?
-50.8478 ^ -1.017
ans =
-0.0183959070209519
K>> x = -50.8478; y = -1.017
K>> x^y
ans =
-0.0183696777893977 + 0.000982004601423454i
采纳的回答
更多回答(1 个)
James Tursa
2020-4-11
编辑:James Tursa
2020-4-11
Operator precedence
>> -50.8478 ^ -1.017
ans =
-0.0184
>> (-50.8478) ^ -1.017
ans =
-0.0184 + 0.0010i
The ^ operator has higher precedence than the - operator when typed in at the command line.
类别
在 帮助中心 和 File Exchange 中查找有关 Get Started with MATLAB 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!