Plot surface in cylindrical coordinate system in matlab -
i have function , want plot 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 , radius of cylinder r=1.
as physical sense can explain if in cartesian coordinate, z & theta x,y axis , w surface on rectangular domain. in cylindrical coordinate z & theta restrict 1 cylindrical piece of cylinder radius=1 w surface on domain.
plotting using cylindrical or spherical coordinates involves several steps:
create vectors
theta
,z
:theta = linspace(0,2*pi); z = linspace(0,10);
create
meshgrid
theta
,z
:[th,z] = meshgrid(theta,z);
write function r(th,z):
r = sin(z)+1+5*sin(th); %// cylinder r = ones(size(z));
convert cylindrical coordinates cartesian:
[x,y,z] = pol2cart(th,r,z);
plot result using
surf
,mesh
or whatever:mesh(x,y,z); axis equal
Comments
Post a Comment