Polarplot all positive values of the angle theta

1 次查看(过去 30 天)
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