フィルターのクリア

Evaluating a function with Matlab

3 ビュー (過去 30 日間)
Danny Guana
Danny Guana 2022 年 5 月 18 日
コメント済み: Danny Guana 2022 年 5 月 18 日
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
KSSV 2022 年 5 月 18 日
t = 10 ;
f = -((t-16.82)/5.604)^1.576
f = -0.3223 + 1.3241i
The result is clear, you are taking exponent of a negative number.

サインインしてコメントする。

採用された回答

Stephen23
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)
f = 1.3627
  1 件のコメント
Danny Guana
Danny Guana 2022 年 5 月 18 日
Many thanks, I understood

サインインしてコメントする。

その他の回答 (1 件)

Torsten
Torsten 2022 年 5 月 18 日
編集済み: Torsten 2022 年 5 月 18 日
Then you have to program it as
t = 10;
f = sign(t-16.82).*abs((t-16.82)/5.604).^1.576
An expression
x^a
for x<0 is complex-valued.
  1 件のコメント
Danny Guana
Danny Guana 2022 年 5 月 18 日
Thanks a lot Torsten

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by