MATLAB Answers

0

How can I polar plot in decibels?

Asked by Pilar Jiménez on 11 Jul 2018
Latest activity Commented on by Pilar Jiménez on 11 Jul 2018
I have the following results in dBs, I need to make a polar graph with these values, but I can not find the correct way to graph them. I hope you can help me, this is the code I have:
puntos=101;
teta=linspace(-pi/2,pi/2,puntos);
corte0=[ -7.838577 -7.832224 -7.813205 -7.781625 -7.737674 -7.681614 -7.613759 -7.534502 -7.44429 -7.343629 -7.233057 -7.113168 -6.984587 -6.847963 -6.703968 -6.553286 -6.396613 -6.234628 -6.068019 -5.897437 -5.723536 -5.54693 -5.368196 -5.187878 -5.006474 -4.824449 -4.642216 -4.460145 -4.278563 -4.097766 -3.918009 -3.739528 -3.562553 -3.387297 -3.214005 -3.042917 -2.874333 -2.708591 -2.546094 -2.387311 -2.232779...
-2.083104 -1.938968 -1.801116 -1.670343 -1.547495 -1.43342 -1.328996 -1.235081 -1.152506 -1.082048 -1.024429 -0.980308 -0.950234 -0.934665 -0.933967 -0.948368 -0.978023 -1.022938 -1.083016 -1.158051 -1.247738 -1.351648 -1.469277 -1.600019 -1.743196 -1.898051 -2.06376 -2.239445 -2.424194 -2.617045 -2.816997 -3.023051 -3.234174 -3.449336 -3.667496 -3.887619 -4.108674 -4.329646 -4.549521 -4.767314 -4.982032 -5.192729...
-5.398455 -5.598276 -5.791293 -5.976641 -6.15345 -6.320908 -6.478218 -6.624628 -6.759425 -6.881949 -6.991595 -7.0878 -7.170061 -7.237973 -7.291164 -7.329369 -7.352368 -7.360037];
parche=db2mag(corte0);
corte90= [-21.7136 -21.422581 -20.646576 -19.587852 -18.420361 -17.246315 -16.113091 -15.037758 -14.023014 -13.065556 -12.159986 -11.300657 -10.482368 -9.700682 -8.951984 -8.233437 -7.54299 -6.879227 -6.241355 -5.629077 -5.042615 -4.482525 -3.949742 -3.4454 -2.970901 -2.527738 -2.117475 -1.741663 -1.401798 -1.09923 -0.835085 -0.61021 -0.425063 -0.279627 -0.173322 -0.104944 -0.072548 -0.073378 -0.10389 -0.159741...
-0.235912 -0.326925 -0.427152 -0.531135 -0.634019 -0.731884 -0.821932 -0.902473 -0.972771 -1.032644 -1.082048 -1.120685 -1.147753 -1.161962 -1.161733 -1.145631 -1.112919 -1.064068 -1.001096 -0.927695 -0.849008 -0.771236 -0.701124 -0.645415 -0.61041 -0.601672 -0.623827 -0.680485 -0.774288 -0.906942 -1.07932 -1.291582 -1.543242 -1.833276 -2.160211 -2.522179 -2.916971 -3.342113 -3.794876 -4.27235 -4.771453 -5.288964...
-5.821557 -6.365805 -6.918194 -7.475142 -8.032939 -8.58776 -9.135592 -9.672182 -10.192956 -10.692926 -11.166648 -11.608166 -12.011011 -12.368385 -12.673313 -12.919049 -13.099545 -13.209938 -13.247106];
parche90=db2mag(corte90);
polar(teta,corte0,'k')
hold on;
polar(teta,corte90)
The objective is to have a graph like this, with the labels in dBs.

  0 Comments

Sign in to comment.

Products


Release

R2014a

2 Answers

Answer by Kelly Kearney
on 11 Jul 2018
 Accepted Answer

If you have a recent version of Matlab (R2016a or later), you can use polaraxes/polarplot to get much more flexibility in setting up your axis:
polaraxes('RLim', [-22 0], ...
'thetadir', 'clockwise', ...
'thetazerolocation', 'top');
hold on;
polarplot(teta, [corte0; corte90]);
If you're running an older version of Matlab, the mmpolar function (available on the File Exchange) offers very similar functionality:
mmpolar(teta, [corte0; corte90], ...
'RLimit', [-22 0], ...
'TDirection', 'cw', ...
'TZeroDirection', 'North');
Both functions allow you to customize many properties of the polar axis, including R- and Theta-limits, angle direction and units, colors, labels, etc. Polaraxes are a little more robust, in that they create modifiable handle objects, but are still pretty limited in what can be plotted (no support of patch objects, for example), so I keep both these functions in my arsenal for now.

  4 Comments

Show 1 older comment
Thank you very much for answering Kelly, I notice that the version I use is really behind in the new functions of Matlab, I use the R2014a version so I do not have the facility to use the first function that you present to me. As for the mmpolar function, I searched for it but it appears on the Mathworks page as a non-available page. It would be very helpful if you could send me the .fig file of the first figure that you show me, do you think it would be possible?
If you're running an older version of Matlab, especially a pre-HG2 version of Matlab (graphics were overhauled in R2014b), I don't believe you'd be able to open the polarplot figure even if I sent it to you.
Looks like the File Exchange is down for maintenance today, but you should be able to download mmpolar as soon as that's back up.
Yes, I will be waiting to download. Meanwhile, I have solved it by asking a partner to lend me his laptop with a newer version. Thank you for your help.

Sign in to comment.


Answer by dpb
on 11 Jul 2018

You're in luck; TMW did introduce a somewhat more capable polar plotting capability in R2016b...
hP=polarplot(teta,corte0,'k');
hold on
hP(2)=polarplot(teta,corte90);
rlim([-40 0])
It still is lacking in some features, amongst which is there is no 'RLabel' nor 'ThetaLabel' property altho there is associated 'xxxTickLabel'. Why left of the overall label is anybody's guess. Anyways, complaints aside...
hAx=gca; % returns a new polaraxis object
hTxt=text(deg2rad(82),4,'dB'); % label for the r-axis units...trial and error to locate

  1 Comment

Thank you very much for the description of the new polar plotting capability, I think it is a very good tool, unfortunately I have a previous version of Matlab, I use the R2014a version. I would be very helpful if you could send me the .fig file, do you think it's possible?

Sign in to comment.