Surface Plot in Matlab (Cylindrical Coordinates)

In summary, the conversation discusses plotting the final solution equation for steady state temperatures in a circular cylinder using MATLAB. The final solution is defined in cylindrical coordinates and involves the use of the functions sinh() and J0(). The solution is not defined in theta and a one-dimensional linspace vector is used for r and z. The question is whether it is possible to display the solution as a surface in MATLAB and if so, how to implement and interpret the plot. The solution is independent of theta and can be plotted in 3D using x and y coordinates on a fine grid.
  • #1
phioder
25
0
Hello

Trying to plot in MATLAB the final solution equation [tex]u(r,z)[/tex] of the steady state temperatures in the circular cylinder

[tex]u(r,z)[/tex] is defined in cylindrical coordinates and I'm confused trying to understand also how MATLAB plots a mesh.

After some simplification The final solution looks like:

[tex]u(r,z) = u_0 \cdot sinh(\lambda z) \cdot J_0(\lambda r)[/tex]

and it is defined in

[tex]0<r<2[/tex]

[tex]0<z<4[/tex]

[tex]\lambda = constant[/tex]

The solution of the problem is not defined in [tex]\theta[/tex] and most of 3d plot examples I have found yet on the web define a theta vector.

In MATLAB a one dimensional linspace vector for r, one for z is defined and later evaluated with sinh() and J0(). The resulting vector are multiplied as sinh().*J0(), to get again a one dimensional vector, all vectors are of the same size, so I suppose the vectors are right.

Now the question is, is it possible to display [tex]u(x,t)[/tex] as a surface with Matlab? If yes, could anyone give me some kind of tip, hint on how to implement and understand the plot?

Best Regards and Thank you
 
Last edited:
Physics news on Phys.org
  • #2
The solution is indepeendent of [itex] \theta [/itex], so it doesn't matter, I'd set [itex] r = \sqrt{x^2+y^2} [/itex] and plot in 3-d on that grid. Make [itex] x [/itex] and [itex] y[/itex] on a fine enough grid that you can get a bunch of points for a smooth surface.
 
  • #3
Hello,

Thank you for reaching out with your question about plotting a surface in MATLAB using cylindrical coordinates. It is definitely possible to display u(r,z) as a surface in MATLAB. Here are some tips and hints to help you understand and implement the plot:

1. First, make sure you have defined your r and z vectors correctly. As you mentioned, the vectors should be one-dimensional and of the same size.

2. Next, you can use the "meshgrid" function in MATLAB to create a grid of points for r and z. This will help you to evaluate the solution at each point on the grid.

3. Once you have your grid, you can use the "surf" function in MATLAB to plot the surface. The syntax for this function is "surf(X,Y,Z)", where X and Y are the grid matrices created using meshgrid, and Z is the evaluated solution u(r,z).

4. You can also use the "shading" option in the "surf" function to control the appearance of the surface. For example, you can use "shading interp" to create a smooth surface or "shading flat" for a flat surface.

5. If you want to add labels and a colorbar to your plot, you can use the "xlabel", "ylabel", and "colorbar" functions in MATLAB.

I hope these tips help you to plot your solution u(r,z) as a surface in MATLAB. If you have any further questions, please don't hesitate to ask. Good luck with your project!
 

FAQ: Surface Plot in Matlab (Cylindrical Coordinates)

1. What is a surface plot in Matlab?

A surface plot in Matlab is a type of graph that displays three-dimensional data in a two-dimensional format. It is often used to visualize complex mathematical functions or data sets that have two input variables and one output variable.

2. How do I create a surface plot in Matlab?

To create a surface plot in Matlab, you can use the "surf" function. This function takes in three input vectors representing the x, y, and z coordinates of the data points and generates a surface plot with those points. You can also customize the appearance of the plot by adjusting parameters such as color, lighting, and shading.

3. What are cylindrical coordinates?

Cylindrical coordinates are a system of representing points in three-dimensional space using a combination of distance, angle, and height. In this system, the distance from the origin is represented by the variable "r", the angle from the x-axis is represented by the variable "theta", and the height along the z-axis is represented by the variable "z". These coordinates are often used in physics and engineering applications.

4. How do I plot data in cylindrical coordinates in Matlab?

To plot data in cylindrical coordinates in Matlab, you can use the "polarplot" function. This function takes in two input vectors representing the angle and distance from the origin and generates a polar plot with those points. You can also use the "cylindrical2cartesian" function to convert your data from cylindrical to Cartesian coordinates for plotting in a surface plot.

5. How can I interpret a surface plot in Matlab?

A surface plot in Matlab can be interpreted by examining the shape and patterns of the graph. The height of the surface at any point represents the value of the function at that point. Flat regions indicate a constant value, while steep regions indicate a rapid change in the function. You can also use the color and shading of the surface to identify different regions or trends in the data.

Similar threads

Replies
1
Views
2K
Replies
1
Views
1K
Replies
2
Views
3K
Replies
1
Views
2K
Replies
1
Views
3K
Replies
2
Views
2K
Replies
2
Views
3K
Replies
5
Views
4K
Replies
7
Views
3K
Back
Top