Why do I have "Warning: Imaginary parts of complex X and/or Y arguments ignored."

1 view (last 30 days)
The line shouldn't stop at 80, it should stop beyond 120 on the x axis, and return to 0 on the y axis. I don't understand why it says I have complex parts in there

Answers (1)

Jon
Jon on 16 Nov 2021
Most likely you are trying to raise a negative value to a fractional power, for example x^0.5 or x^0.4 where x is negative.
This results in a complex value which then causes problems a little later in your code.
  1 Comment
Jon
Jon on 16 Nov 2021
I put a conditional breakpoint at line 34 inGolfModelBottomSpin3, just after calculating the drag coefficient. I found that this expression
Cd = 0.55 + 1/(22.5 + 4.2*Spara^2.5)^0.4;
produced a complex result. Drilling down a little more I see that Spara is negative so Spara^2.5 is complex
So if the algebraic sign of Spara is not important (same value of Cd) I would suggest using abs(Spara)^2.5

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!