Code covered by the BSD License  

Highlights from
Polar 2

5.0

5.0 | 6 ratings Rate this file 67 Downloads (last 30 days) File Size: 3.86 KB File ID: #23589

Polar 2

by

 

08 Apr 2009 (Updated )

An update to Matlabs built-in polar.m

| Watch this File

File Information
Description

A polar plot script that allows selection of axis limits by the user, including negative radial limits. It is particularly appropriate for logarithmic data.

A known limitation is that datapoints outside the radial limits will still be drawn.

Acknowledgements

Advanced Polar Plots V2 inspired this file.

MATLAB release MATLAB 7.14 (R2012a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (28)
25 Feb 2014 Jaroslaw Tuszynski

That was exactly what I needed

24 Jul 2013 Linus

A very nice improvement compared to the orignial polar plotter! Though I have a problem:

When ever I try to plot multiple traces with radial limits in one figure, the colour is always blue.

example code:
polar2([0:2*pi; 0:2*pi]', [1:7 ; 7:-1:1]',[0 10])

Have any ideas to why?

30 Jun 2013 Vadim Smolyakov  
29 May 2012 Peter

If there /is/ to be an updated version of polar2.m at any point, it would be fantastic if it could also give the user control over the number and or spacing of the rho-axis gridlines... something akin to the 'ytick' parameter in cartesian axes. Thanks again!

29 May 2012 Peter

Wow -thanks Daniel, I look forward to any updates that may be available!

28 May 2012 Daniel Armyr

OK, I wrote an updated version that incormporates your ideas, Peter. However, as I am now a MathWorks employee, there might be issues with me publishing that update. I will comment again when and if an update is released.

27 May 2012 Daniel Armyr

These are limitations in the current version of polar2, yes. But they are not limitations that are more complex than that maybe I can fix them tomorrow.

25 May 2012 Peter

Daniel - Thanks for filling the polar plot gap for those of us who work with dB attenuation. I've been using your older 'pp.m' for several years now. Despite it's girth and bugginess, I've come to love the control it grants over the graphical aspects of the plot, such as 'ThetaStartAngle' and 'ThetaDirection'.

I'm working on creating a GUI with a polar plot in it. Reading through the comments on the 'pp' page, I gather that we can't use pp to plot into existing axes (or subplots, for that matter), hence 'polar2.'

So, now I can plot my polar into the axes of my choice - Great! But, I seem to lose control over the orientation of the polar coordinate system and the theta direction. Is there a way to set 0 degrees at the top of the plot and plot clockwise?

Additionally, it appears that rho values that are more negative than the 'CenterValue' aren't truncated, as with pp.m. Instead, they appear to be plotted 'through' the center of the plot, 180 degrees off. in pseudo-code,

if rho < CenterValue
plot( (theta - pi), (CenterValue - rho) )

Is this a fundamental limitation in polar2, or is there a workaround (other than setting CenterValue < min(rho) )?

Thanks!

06 May 2012 Daniel Armyr

Well, you should be able to use the polar2(AX,...) syntax. I haven't tried it, but if that works wit the original polar, it should work with polar2.

It is always better if you can send the axes as an argument to the function rather than to first set the axes and then plotting. In GUIs, things can happen that change the CGA even between two lines of code in the same function.

05 May 2012 LORENA

Daniel, thank you very much. The answer is similar a your piece of advice. I do:

axes(handles.PH)
polar2(...)

I have written a lot about set, get, gcf,gca... and now I have just got the answer! :)

05 May 2012 LORENA

The thing that I would like to know is how draw in the graphical user interface GUIDE, how programm my axes (objects handles).

I have two axes in my graphical user interface: PH and PV.

With polar is:
polar(handles.PH,ang,va);
(theta=ang, rho=va)

How is with polar2?

04 May 2012 Daniel Armyr

If I understand you correctly, this is what you would do:

<code>
subplot ( 2, 1, 1 );
polar2((1:360)*pi/360,-60*rand(1,360),[-60 0])
subplot ( 2, 1, 2 );
polar2((1:360)*pi/360,-60*rand(1,360),[-60 0])
</code>

03 May 2012 LORENA

Hello Daniel,
I have written you a pp.m. If I have understood you good, I writte you here. In my GUI I have two axes where I want to draw a radiation pattern (planes horizontal and vertical). The values are negative y therefore I want to use polar2.m. How can I draw in my axes? For example:
polar2(handles.PH,(1:360)*pi/360,values,'MaxValue',0,'CentreValue',-60))

19 Apr 2012 christophe  
10 Apr 2012 7ate9  
19 May 2011 Jochen  
14 Sep 2010 Daniel Armyr

@senthil: I am sorry, but I do not udnerstand your question. You seem to have an idea of what your theta values shoudl be. In that case, can't you just set your theta values to what you want and plot it?

13 Sep 2010 senthil

I am using ur polar2.m file for plotting. If i have some 2000 rho values in set A, Is it possible to push the data (theta) to start from say 700 to 2700. so i the initial part will be blank. This i need to do (by hold ON) on 4 set of values that will be over laid. so finally i will get concentric ring of values while the central 700 region is empty.

28 Jun 2010 Daniel Armyr

@Faisal: Two examples are provided here in the thread. Try Judy's and Jerrys examples and see where that leads you.

25 Jun 2010 Faisal

mr daniel, can u send ur demo on this case..

i have case, and im using ur formula, but... the result i have is strange..
i mean the figure result its not logic to me...

20 May 2010 Jerry Gump

Solution to my question is:

angle=[0.03*pi:0.01*pi:0.25*pi];
radius=ones(size(angle));
radius(1)=0;radius(size(angle))=0;
h=polar(angle,radius,'g');
patch(get(h,'XData'),get(h,'YData'),[0 1 1]);
hold on;
t = 0:.01:2*pi;
polar(t,sin(2*t).*cos(2*t),'r')

20 May 2010 Daniel Armyr

@Jerry: Sorry, there are few options for polar plotting in Matlab. Maybe if you ask in the newsgroup you might find something.

19 May 2010 Jerry Gump

Do we have anything that works similar to shade command for rectangular plots? We am making a polar plot and I want to shade the region between the two angles.

22 Jan 2010 Daniel Armyr

@Judy: Well, actually. This is the Mathworks original polar.m with just a few modifications to get the features I wanted. So unfortunately, I can't answer for that part of the code since I didn't write it.

21 Jan 2010 Judy

Actually, looking into this more, this actually does plot the graph, but the error keeps coming up, so I just commented the last part out. I don't think it is necessary? What was the purpose for making the mcode at the end? Thank you!!

21 Jan 2010 Daniel Armyr

@Judy:
I redownloaded the code from here, and cut and pasted your two-line example directly into my command window. I get a nice flower-petal plot with no errors.

This file has only been tested with Matlab2009a and 2009b. What version are you running?

20 Jan 2010 Judy

The code is giving me an error of

??? Error using ==> makemcode>local_parse_input
Invalid input

Error in ==> makemcode at 38
[h,options] = local_parse_input(varargin{:});

Error in ==> polar2 at 249
makemcode('RegisterHandle',cax,'IgnoreHandle',q,'FunctionName','polar');

when I try to plot a simple example for a polar plot with
t = 0:.01:2*pi;
polar2(t,sin(2*t).*cos(2*t))

What is going on?

15 Jan 2010 Claudio Pedrazzi

I was looking exactly for this! It is strange that the "polar" function supplied by MATLAB does not provide the facility to set the axis limits. Thanks a lot!

Updates
14 Apr 2009

Edited the description.

28 May 2012

Added support for anglular limits and cropping out-of-bounds values.

13 Aug 2012

Now handles values less than minimum better. Reassigned copyright to MathWorks.

13 Aug 2012

Reupploaded as the file did not get properly updated.

09 Sep 2013

Fixed the drawing of multiple lines so they get different colors.

Contact us