Polarplot all positive values of the angle theta

조회 수: 1 (최근 30일)
KG573
KG573 2022년 3월 13일
답변: Simon Chan 2022년 3월 13일
Hello, i'm trying to get my plot to look like this:
It currently looks like this:
Here is my Code for the plot above:
theta = linspace(-pi,pi,1000);
theta_deg = rad2deg(theta);
EF = cos(theta);
y = polarplot(theta,10*log10(EF),'linewidth',3);
title('E Field (dB)');
legend('\theta = \pi/4');
set(gca,'fontsize',12);
ax = ancestor(y,'polaraxes');
ax.ThetaZeroLocation = 'top';
ax.ThetaDir = 'clockwise';
ax.ThetaLim = [-180 180];
rlim([-40 0])

채택된 답변

Simon Chan
Simon Chan 2022년 3월 13일
Workaround by modifying the TickLabel as follows:
theta = linspace(-pi,pi,1000);
theta_deg = rad2deg(theta);
EF = cos(theta);
y = polarplot(theta,real(10*log10(EF)),'linewidth',3); % Plot the real part only, prevent warning pop-up
title('E Field (dB)');
legend('\theta = \pi/4');
set(gca,'fontsize',12);
ax = ancestor(y,'polaraxes');
ax.ThetaZeroLocation = 'top';
ax.ThetaDir = 'clockwise';
ax.ThetaLim = [-180 180];
rlim([-40 0]);
ax.ThetaTickLabel = string(abs(ax.ThetaTick)); %% <-- Add this line

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by