double precision becomes complex double after calculation

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 개 추천

-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.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

질문:

CAL
2018년 8월 21일

댓글:

CAL
2018년 8월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by