Reputation: 1
I have a function and want to plot it on cylindrical coordinate.
w(z,theta)=sin(n.pi.z/a).sin(m.theta)
The limits of variables are: z=0..a , theta=0..theta_0 and radius of cylinder is R=1.
As a physical sense I can explain that if we in the Cartesian coordinate, z & theta are x,y axis and w is surface on this rectangular domain. But in cylindrical coordinate z & theta restrict one cylindrical piece of cylinder with radius=1 that w is surface on this domain.
Upvotes: 0
Views: 8739
Reputation: 1345
Plotting using cylindrical or spherical coordinates involves several steps:
Create vectors for theta
and z
:
theta = linspace(0,2*pi); z = linspace(0,10);
Create a meshgrid
from theta
and z
:
[TH,Z] = meshgrid(theta,z);
Write your function R(TH,Z):
R = sin(Z)+1+5*sin(TH); %// For cylinder it would be simply R = ones(size(Z));
Convert cylindrical coordinates to cartesian:
[x,y,z] = pol2cart(TH,R,Z);
Plot the result using surf
, mesh
or whatever:
mesh(x,y,z); axis equal
Upvotes: 2