Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Plot Cylindrical coordinates

Subject: Plot Cylindrical coordinates

From: Lorenzo

Date: 1 Jan, 2009 16:14:08

Message: 1 of 4

Hi everybody and happy new year!

I need to plot some pressure values upon a circle, so I have to work in cylindrical coordinates, ma I couldn't find a way to do it...

The problem is this: I have the pressures values taken at some point upon the cylinder surface, the values I have are simple scalar, so I have a pressure vector: P=[p1 p2 p3 p4...] and every pressure value is taken for a certain angle upon the circular cylinder surface, TH=[th1 th2 th3 th4...] so what I want is: draw a circle (and I know how to do it) and then plot every pressure value for every angle starting from the circle border and going away from it...
Any idea?

Thanx

Lorenzo

Subject: Plot Cylindrical coordinates

From: someone

Date: 1 Jan, 2009 18:43:02

Message: 2 of 4

Lorenzo <liquidcrystal@tiscali.it> wrote in message <27115565.1230826478876.JavaMail.jakarta@nitrogen.mathforum.org>...
> Hi everybody and happy new year!
>
> I need to plot some pressure values upon a circle, so I have to work in cylindrical coordinates, ma I couldn't find a way to do it...
>
> The problem is this: I have the pressures values taken at some point upon the cylinder surface, the values I have are simple scalar, so I have a pressure vector: P=[p1 p2 p3 p4...] and every pressure value is taken for a certain angle upon the circular cylinder surface, TH=[th1 th2 th3 th4...] so what I want is: draw a circle (and I know how to do it) and then plot every pressure value for every angle starting from the circle border and going away from it...
> Any idea?
>
> Thanx
>
> Lorenzo

% use pol2cart to convert from cylindrical to cartesian:

doc pol2cart

% then plot the surface using meshgrid and contour, surf, etc.

doc meshgrid
doc contour
doc contourf
doc surf

Subject: Plot Cylindrical coordinates

From: Roger Stafford

Date: 1 Jan, 2009 21:58:01

Message: 3 of 4

Lorenzo <liquidcrystal@tiscali.it> wrote in message <27115565.1230826478876.JavaMail.jakarta@nitrogen.mathforum.org>...
> I need to plot some pressure values upon a circle, so I have to work in cylindrical coordinates, ma I couldn't find a way to do it...
> The problem is this: I have the pressures values taken at some point upon the cylinder surface, the values I have are simple scalar, so I have a pressure vector: P=[p1 p2 p3 p4...] and every pressure value is taken for a certain angle upon the circular cylinder surface, TH=[th1 th2 th3 th4...] so what I want is: draw a circle (and I know how to do it) and then plot every pressure value for every angle starting from the circle border and going away from it...
> Any idea?
> Thanx
> Lorenzo

  I am not completely clear about what you are proposing to do, Lorenzo. Do the pressures you have vary with distance along the axis of the cylinder as well as with the angle about that axis? If so, it sounds as though you are attempting to flatten these cylindrical coordinates of axial distance and angle into a circular annulus where radial distance replaces the previous distance along the cylinder axis. What gives me that idea is your statement "draw a circle ... and then plot every pressure value for every angle starting from the circle border and going away from it." Indeed that would allow you to depict your results with a 'surf' plot, even if it is somewhat of a distortion of the original cylinder.

  As 'someone' says, for this you need 'meshgrid' to generate rectangular matrices of R and A values (radial distance and angle) over some mesh of values that corresponds to the P values you have. That is, with each R(i,j) and A(i,j) the value in P(i,j) should be the corresponding pressure, (and consequently your three matrices R, A, and P must all be of the same size for each dimensions.) With 'pol2cart' you can then convert R and A into corresponding X and Y matrices, and then use X, Y, and P in 'surf'.

  Don't be discouraged by the rather misleading statement in matlab's 7.5 document about 'surf' that you "Use surf and surfc to view mathematical functions over a rectangular region." Your annulus certainly isn't a rectangular region. However, it is the index space that 'surf' needs to have rectangular, not the x and y coordinate space, as you will see further on in the "Algorithm" section.

  It also occurs to me that, contrary to the above, your pressures might be varying only with angle and you wish to depict this in a two-dimensional plot using pressure as radial distance from a center and varying with the angle. That is a much easier problem. Use angle and pressure as the respective theta and rho inputs to 'pol2cart' to get vectors x and y, and then use 'plot' with x and y. No surfaces are involved.

Roger Stafford

Subject: Plot Cylindrical coordinates

From: Lorenzo

Date: 2 Jan, 2009 10:21:54

Message: 4 of 4

Thank You both!
I solved my problem using "polar(th,p*)" where th is the angle and p* is the value of pressure (Pressure coefficient actually) plus the cylinder radius. I didn't find the polar function because I looked for "cylindrical" instead of "polar" inside the help.

I have to make just 2-D plots for every value of a z coordinate along the cylinder axis.

Greetings

Lorenzo

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us