1

I have a simple function of theta and I want to plot this function in dB using the polarplot function in MATLAB. But when I make the graph from -40 to 0, the graph seems to have a strange part around horizontal axis. My MATLAB code (R2016a) is:

%% Define range of plotting angle.
ceta= [10^-9:0.0001:2*pi];
% ceta starts not from pure zero to avoid 0/0 in some cases.

E =  abs( ( cos((cos(ceta))*pi/2) ) ./ ( sin(ceta) ) ); 

power_dB = 10.*log10(E.^2); 
power_dB = power_dB - max(power_dB);
max(power_dB)
polarplot(ceta,power_dB);
rlim([-40 0]); 

The obtained figure is this: plot resulting from code

1 Answer 1

4

Your values for E are very near to 0 when ceta = 0, pi, or 2pi. This is resulting in very large values when you take the log of E.

You can just remove the points from ceta and E when E is very low. See the code block below.

E =  abs( (  cos((cos(ceta))*pi/2) ) ./ ( sin(ceta) ) ); 
ceta(E<1e-2) = [];
E(E<1e-2) = []; 
power_dB = 10.*log10(E.^2); 
power_dB = power_dB - max(power_dB);
max(power_dB)
polarplot(ceta,power_dB);
rlim([-40 0]);

Gives:

enter image description here

Sign up to request clarification or add additional context in comments.

4 Comments

i have a question, when 10*log10(E.^2) tends to large value i think rlim([ -40 0]) should remove it so why that is not happened?
rlim is only controlling the figure axis. What's happening is as you plot value larger than -40 (in terms of magnitude) its passing through the origin and continuing to the edges of the plot. Try this, remove the line I suggested and add in power_dB(power_dB < -60) = -60 right before your polar plot. You'll see the lines come back, but stop at 2 circles out from the center. This represents the -60 value once they've passed through the origin.
Also, looking at this a second time better solution might have been to just use power_dB(power_dB < -40) = -40, rather than my suggested change.
E = abs(cos(cos(ceta)*pi/2) ./ sin(ceta)); would suffice, cutting down on the LISP style usage of brackets.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.