Cannot stop warning from compassplot

이 질문에 Walter Roberson 님이 플래그를 지정함
  • Walter Roberson 님이 2025년 12월 19일에 중복 질문(으)로 플래그를 지정했습니다.

    duplicates https://www.mathworks.com/matlabcentral/answers/2181725-need-to-stop-warning-because-i-need-to-not-show-a-plot-using-compassplot

X = compassplot(ones)
Here is the code that produces the warning
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.
> In compassplot>matrixCompassPlot (line 89)
In
compassplot (line 29)

답변 (1개)

Benjamin Kraus
Benjamin Kraus 2026년 1월 6일
편집: Benjamin Kraus 2026년 1월 6일

0 개 추천

The compass command supports two valid syntaxes:
  • compassplot(theta, rho)
  • compassplot(Z) - With this syntax, the angle(Z) is used for theta and the abs(Z) is used for rho.
This is different from something like polarplot which supports these three syntaxes:
  • polarplot(theta, rho)
  • polarplot(rho) - With this syntax, the input rho is used and theta is calculated to be evenly spaced angles between 0 and 2π.
  • polarplot(Z) - With this syntax, the angle(Z) is used for theta and the abs(Z) is used for rho.
The way MATLAB differentiates between polarplot(rho) and polarplot(Z) is whether the data is complex or all real, but that means a radically different behavior if your data happens to be all real one day and complex the next. To avoid that ambiguity, compassplot only supports the complex syntax. However, because of the difference in behavior between compassplot and polarplot MATLAB issues a warning so that you don't misinterpret your data.
If you want to avoid the warning, you can either:
  • Explicitly specify both theta and rho.
  • Suppress the warning.
You can see the difference in behavior between compassplot and polarplot with this example:
warning('off','MATLAB:polar:AssumeComplex')
nexttile
theta = linspace(0,2*pi,5);
rho = ones(1,5);
polarplot(rho)
nexttile
compassplot(rho)
nexttile
polarplot(theta, rho)
nexttile
compassplot(theta, rho)

카테고리

도움말 센터File Exchange에서 Polar Plots에 대해 자세히 알아보기

제품

릴리스

R2025b

태그

질문:

2025년 12월 19일

편집:

2026년 1월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by