Code covered by the BSD License  

Highlights from
Polar contour plot

4.4

4.4 | 5 ratings Rate this file 14 Downloads (last 30 days) File Size: 1.64 KB File ID: #14826
image thumbnail

Polar contour plot

by Richard Rieber

 

28 Apr 2007 (Updated 18 Jun 2007)

Creates a contour plot from polar coordinates

| Watch this File

File Information
Description

Have you ever wanted to do a contour plot of data in polar coordinates but didn't want to go through the hassle of converting it all to Cartesian coordinates? Well if so, here's your answer. A simple scriptlet that works exactly like MATLAB's built in contour plotting function. You can use clabel and handles just like contour. And if you don't like it, I'll give 100% of your money back (less S&H)

MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (6)
30 Apr 2007 John D'Errico

I could see that this might be a useful tool if you work with polar data.

What was good? Good help.

What could be far better?

- This code uses a double loop to do what ndgrid will do in one line. Loops are not bad in themselves, but then the author fails to pre-allocate the arrays that grow inside that loop. (Note that mlint points out this problem.)

- No error checks. When I tested this, I tried a few things, only to see empty figures. It turns out my z array was transposed. Yes, I found my error, but why not check a few sizes and tell the user what they did wrong?

- No H1 line, so lookfor will never find this code. Next year, when you are trying to remember the name of this function, lookfor won't be any help to you.

16 Jun 2007 Richard Rieber

Made the changes that Mr. D'Errico recommended. Added an H1 line, error checks on array sizes, and preallocated memory before the nested for loops.

31 Oct 2007 eric meier

awesome to find this handy code! thanks Richard.

23 May 2008 Alasdair Thom

Lovely Stuff

26 Jul 2009 Sean

Would be nice if there were a contour fill option.

07 Oct 2009 Dominique

Sean
replace contour by countourf in the code, there are 3 instances, lines 52 54 and 56

Also, if you want 0 degree to be up and clockwise to be positive (wind and wave data for example) replace
line 45 and 46 by:
x(j,k) = -r(j)*cos(theta(k)+pi/2);
  y(j,k) = +r(j)*sin(theta(k)+pi/2);

Richard- Thank for the script. Very useful!, eventhough I did have to transpose Z compare to the function contour. Not a big deal.

Please login to add a comment or rating.
Updates
18 Jun 2007

- Added a line for LOOKFOR compatibility
 - Preallocated memory before nested for loops
 - Added error detection for an improperly sized or transposed input matrix

Tag Activity for this File
Tag Applied By Date/Time
specialized Richard Rieber 22 Oct 2008 09:11:06
plotting Richard Rieber 22 Oct 2008 09:11:06
polar Richard Rieber 22 Oct 2008 09:11:06
graphic Richard Rieber 22 Oct 2008 09:11:06
contour Richard Rieber 22 Oct 2008 09:11:06
plot Richard Rieber 22 Oct 2008 09:11:06
contour Anup.shr Shrestha 19 Sep 2010 13:38:19
contour Alireza Hassani 04 May 2011 11:45:01

Contact us at files@mathworks.com