double precision becomes complex double after calculation

3 ビュー (過去 30 日間)
CAL
CAL 2018 年 8 月 21 日
コメント済み: CAL 2018 年 8 月 22 日
The outputs for c1(p) becomes complex double after calculation. However, it should be double precision since I am just raising the power of the element. Is there any possibility to fix it? I calculated manually and all the outputs should be double precision.

採用された回答

Steven Lord
Steven Lord 2018 年 8 月 21 日
-1 is real. 0.5 is real. (-1)^(0.5) is complex. There's nothing to "fix" as that's the expected behavior.
If you want MATLAB to throw an error when you raise a real number to a real power and would receive a complex result, use the realpow function.
  1 件のコメント
CAL
CAL 2018 年 8 月 22 日
Thank you very much!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by