Evaluating a function with Matlab
1 次查看(过去 30 天)
显示 更早的评论
Hello friends,
Can anyone help me figure out why I am getting an imaginary number in the following code:
I am supposed to get 1.36. I have done the same calculation using my scientific calculator and symbolab and cannot find what the error is in my code.
1 个评论
KSSV
2022-5-18
t = 10 ;
f = -((t-16.82)/5.604)^1.576
The result is clear, you are taking exponent of a negative number.
采纳的回答
Stephen23
2022-5-18
编辑:Stephen23
2022-5-18
"Can anyone help me figure out why I am getting an imaginary number in the following code:"
Because you are taking the power of a negative number.
"I am supposed to get 1.36."
The simple, effiicient, MATLAB approach is to use REALPOW:
t = 10 ;
f = realpow(-((t-16.82)/5.604),1.576)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!