Need to stop warning because i need to not show a plot using compassplot

22 次查看(过去 30 天)
Warning: Plotting the real and imaginary components of the value provided. Specify both R and Theta values if you do not intend to plot a complex value.

采纳的回答

Norman
Norman 2025-12-19
Here is the code that gives the warning
X = compassplot(ones)
  3 个评论
Walter Roberson
Walter Roberson 2025-12-19
Oddly enough, if you do provide something with real and imaginary components, you do not get the warning.
compassplot(1)
Warning: Plotting the real and imaginary components of the value provided. Specify both R and Theta values if you do not intend to plot a complex value.
compassplot(1+2i)
Paul
Paul 2025-12-19
I can only guess from the text of the warning that the developers assume that if the user inputs a value with a non-zero imaginary part that the user meant it, but if the input has zero imaginary part then the user might be making a mistake (not sure what that mistake could be). But I could be wrong because the behavior is documented, though one could argue it could be a tad more clear on this particular case. Personally, I think this warning is overkill, though I'd be interested if there's some corner case where it helps keep the user from doing something unintended.
Note that the warning still shows up even if the input explicitly has a complex attribute
x = complex(1,0);
whos x
Name Size Bytes Class Attributes x 1x1 16 double complex
compassplot(x)
Warning: Plotting the real and imaginary components of the value provided. Specify both R and Theta values if you do not intend to plot a complex value.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

产品


版本

R2025b

Community Treasure Hunt

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

Start Hunting!

Translated by