How do you create a surf plot in cylindrical coordinates?

Illustration
ishitaisha68 - 2020-09-07T10:53:32+00:00
Question: How do you create a surf plot in cylindrical coordinates?

In general, the syntax for a surf plot is surf(X,Y,Z). I have u = F(r,z). I'd like to do surface plots of u for multiple cross sections at z = h1, h2, h3, etc. Is there a simple way to create a surf plot in cylindrical coordinates, i.e., something that would be analagous to the syntax: surf(r,phi,u) where u = u(r,h1)?

Expert Answer

Profile picture of John Michell John Michell answered . 2025-11-20

### Creating a Surf Plot in Cylindrical Coordinates with MATLAB

Creating a surf plot in cylindrical coordinates is a powerful way to visualize data. Here's a step-by-step guide:

1. Define the Cylindrical Coordinates:
   First, set up the cylindrical coordinates `(r, theta, z)`.

   
   r = linspace(0, 10, 100);  % Radius values
   theta = linspace(0, 2*pi, 100);  % Angle values
   [R, Theta] = meshgrid(r, theta);  % Create a grid
   

2. Convert to Cartesian Coordinates:
   Convert the cylindrical coordinates to Cartesian coordinates `(x, y, z)`.

   
   X = R .* cos(Theta);
   Y = R .* sin(Theta);
   Z = someFunction(R, Theta);  % Replace with your function for z-values
   

3. Create the Surf Plot:
   Use the `surf` function to create the surface plot.

   
   surf(X, Y, Z);
   

4. Label and Customize the Plot:
   Add labels and customize the appearance of the plot.

   
   xlabel('X');
   ylabel('Y');
   zlabel('Z');
   title('Surf Plot in Cylindrical Coordinates');
   colorbar;  % Add a color bar for reference
 

Using these steps, you can effectively create a surf plot in cylindrical coordinates, offering a comprehensive visualization of your data in MATLAB.

 


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!