Clear Filters
Clear Filters

Polarplot all positive values of the angle theta

1 view (last 30 days)
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])

Accepted Answer

Simon Chan
Simon Chan on 13 Mar 2022
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

More Answers (0)

Categories

Find more on Polar Plots in Help Center and File Exchange

Tags

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!