Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Polar plot with dB scale

3,488 views
Skip to first unread message

Jennifer Cohen

unread,
Aug 6, 2007, 9:10:28 AM8/6/07
to
I am trying to plot radiation patterns for antennas on a
polar plot. Any ideas how I can convert the rho axis to a
log scale? Im using version 6.5

Chi Zhang

unread,
Oct 29, 2007, 7:45:13 PM10/29/07
to
I want to know the answer as well, anyone can help?

Chi Zhang

unread,
Oct 29, 2007, 7:49:37 PM10/29/07
to
I want to know the answer too, anyone help please?

Chi Zhang

unread,
Oct 29, 2007, 8:12:08 PM10/29/07
to
Hi Roberson, thank you for replying so quickly! I think I
didn't state the problem clearly: it is the axis I want to
change, not the plot itself. Actually I want my plot's rho
scale to be (from out-side most circle in) 0dB, 10dB,
20dB,and 30dB, instead of the linear scale (from inside out)
0, 2, 4, 6, 8, 10. Thanks a lot for anyone helps, really
really appreciate it!!!

Walter Roberson

unread,
Oct 29, 2007, 11:09:11 PM10/29/07
to
In article <fg5sso$se2$1...@fred.mathworks.com>,

Chi Zhang <ela...@gmail.com> wrote:
>Hi Roberson, thank you for replying so quickly!

'Roberson' is my family name; my given name is 'Walter'.

>I think I
>didn't state the problem clearly: it is the axis I want to
>change, not the plot itself. Actually I want my plot's rho
>scale to be (from out-side most circle in) 0dB, 10dB,
>20dB,and 30dB, instead of the linear scale (from inside out)
>0, 2, 4, 6, 8, 10. Thanks a lot for anyone helps, really
>really appreciate it!!!

polar(1:10,1:10);
set(findobj(gca, 'String', ' 10'),'String', '0 dB');
set(findobj(gca, 'String', ' 8'),'String', '10 dB');
set(findobj(gca, 'String', ' 6'),'String', '20 dB');
set(findobj(gca, 'String', ' 4'),'String', '30 dB');
set(findobj(gca, 'String', ' 2'),'String', '40 dB');

To automate this more, you can find out what the strings
are that you need to replace:

yticks = get(gca,'YTick');
yticklabs = get(gca,'YTickLabel');
activelabs = cellstr(yticklabs(yticks>0,:));
numlabs = length(activelabs);
for K=1:numlabs
set(findobj(gca, 'String', [' ' activelabs{K}]), ...
'String', num2str(10*(numlabs-K),'%d dB'));
end


I don't promise that the pattern will always be two spaces followed
by the tick label; that was the pattern in the tests I did.
--
"No one has the right to destroy another person's belief by
demanding empirical evidence." -- Ann Landers

Chi Zhang

unread,
Nov 2, 2007, 1:39:38 PM11/2/07
to
Hi,thank you so much for helping. I tried the code you
suggested, instead of giving flower petals like radiation
pattern, it gave me some spirals...I think it might just be
a small trick, as all I want to do is to change the linear
polar plot into semi log polar plot, just as people can
change x(linear)-y(linear)plot into x(linear)-y(log)plot, by
typing 'semilog'.I have checked website and help doc I got,
no answer found. Any ideas?

Walter Roberson

unread,
Nov 2, 2007, 4:47:17 PM11/2/07
to
In article <fgfncq$pni$1...@fred.mathworks.com>,

Chi Zhang <ela...@gmail.com> wrote:
>Hi,thank you so much for helping. I tried the code you
>suggested, instead of giving flower petals like radiation
>pattern, it gave me some spirals...

You said, "I want the axis to change, not the plot itself".
So the code doesn't change the plot, just how the plot is labelled.

If you are getting spirals and you want flower petals, then it
is likely that you need a log() taken at some point. So use the
code I provided and pass in the log() of your current rho data.


>I think it might just be
>a small trick, as all I want to do is to change the linear
>polar plot into semi log polar plot, just as people can
>change x(linear)-y(linear)plot into x(linear)-y(log)plot, by
>typing 'semilog'.I have checked website and help doc I got,
>no answer found. Any ideas?

No, it isn't just "a small trick". Matlab does not support
semi-log plots; as I pointed out in another posting in this thread,
doing so would require an infinite plot because of the infinity
of log(x) where x is 0 to 1. The best you can do is trick polar()
to relabel the concentric circles.

Within the last few days I have been in contact with Mathworks support
on the issue of using log() and polar() [I found a some bugs in the polar
plotting routines], and the official word from them is that there is
no support for log polar plots.
--
"All is vanity." -- Ecclesiastes

Markus Buehren

unread,
Nov 2, 2007, 6:38:28 PM11/2/07
to
Use mmpolar from the file exchange!

Markus

zarreen

unread,
Jun 19, 2008, 6:39:02 AM6/19/08
to
"Jennifer Cohen" <j_c...@hotmail.com> wrote in message
<f976k4$j8k$1...@fred.mathworks.com>...

Andres Romero

unread,
May 5, 2010, 7:15:21 AM5/5/10
to
Hi, I had the same problem but I figured out a way to solve it:
Linear values below 0 are negative values in the logarithmic scale, so polar plot takes the absolute value instead.
If you want a logarithmic plot of a function x(theta) in a logarithmic scale that goes between -40 and 0 dB you should write

polar(theta,40-10*log10(x))

Your polar plot will then have values between 0 and 40. You can then manually change the value of 40 to 10dB (edit plot, double click in the 0 value)

Florian

unread,
Dec 27, 2011, 4:13:08 PM12/27/11
to
"Jennifer Cohen" <j_c...@hotmail.com> wrote in message <f976k4$j8k$1...@fred.mathworks.com>...
> I am trying to plot radiation patterns for antennas on a
> polar plot. Any ideas how I can convert the rho axis to a
> log scale? Im using version 6.5


1) converting the function in log
2)calculating the amplitude at -10db, -20db, -30db etc...
3)Dividing by the max in log of the function
4)ploting in polar
5)editing the plot and removing the linear axes (with matlab directly on the figure)
6)editing the values of the axes in dB on the plot (with matlab directly on the figure)


My code :
%-3dB
for j=1:100
db3(j)=20*log10(max(averagetab)/2);
end

%-10dB
for j=1:100
db10(j)=20*log10(max(averagetab)/3.16);
end

%-20dB
for j=1:100
db20(j)=20*log10(max(averagetab)/10);
end

%-30dB
for j=1:100
db30(j)=20*log10(max(averagetab)/30);
end




%Decibel conversion
for j=1:lgth
if(averagetab(j)>1)
averagetab(j)=20*log10(averagetab(j));
else
averagetab(j)=0;
end
end


%Normalizing to 0dB
db3=db3/(max(averagetab));
db10=db10/(max(averagetab));
db20=db20/(max(averagetab));
db30=db30/(max(averagetab));
averagetab=averagetab/(max(averagetab));

phi = linspace(0,2*pi,100);

......


figure(2)

polar(f,v,'r')
hold
polar(phi,db3)


polar(phi,db10,'black--')
polar(phi,db20,'black--')
polar(phi,db30,'black--')

%Cheeeeersss

Sahin

unread,
Apr 6, 2014, 6:21:11 PM4/6/14
to
Hi. I'm nearly new at matlab and i drew this figure:
theta=linspace(0,2*pi);
r=cos(theta);
polar(theta,40+10*log10(r))
Now, I need to turn this graphic 90 degree through left. I mean that zero degree should be on the top, not on the right anymore. Adding pi/2 degree to the theta is an option, but I want "zero degree symbol" to be on the top. All degrees should be shifted 90 degree.

Also I want dB in order of 40-30-20-10-0 (not 0-10-20-30-40). Editing them by hand is an option. I wonder if there's a code I can simply do that easier.
Thanks for your attention..

Kelly Kearney

unread,
Apr 7, 2014, 11:20:12 AM4/7/14
to
"Sahin" wrote in message <lhsk0n$l88$1...@newscl01ah.mathworks.com>...
I've found mmpolar to be pretty good for any polar plot customization:

http://www.mathworks.com/matlabcentral/fileexchange/38855-comprehensive-polar-plots

-Kelly
0 new messages