MATLAB 3D drawing

Source: Internet
Author: User

MATLAB 3D drawing mainly has three commands: The plot3 command, the mesh command, and the SURF command.

    • Plot3
Plot3 is the basic function of 3D drawing. It draws the most important 3D graph. The most important calling format is:

Plot3 (x, y, z)

When x, y, and z are vectors of the same length, the plot3 command will plot a curve with the X, Y, and Z vectors as (x, y, z) coordinate values respectively.

When x, y, and z are all M * n matrices, the plot3 command will plot M curves, with each curve being x, y, and z column vectors (x, y, z) coordinate value curve

    • Mesh
The difference between mesh and plot3 is that it can draw a complete surface (grid chart) within a certain range ). The most important call format is:

Mesh (x, y, z)

Note that X and Y must be vectors. If the lengths of X and Y are M and N respectively, Z must be a matrix of M * n, that is, [m, n] = size (Z). In this case, the vertex of the gridline is(X (J), y (I), Z (I, j ))

    • Surf
The calling method of surf is similar to the mesh command. The difference is that the image drawn by the mesh function is a mesh image, while the surf command draws a colored three-dimensional surface. After obtaining the corresponding grid, the color of the grid is defined for each grid based on the color value of the nodes represented by the grid. The most basic call format is:

Surf (x, y, z)

Note: first, surf only supports Cartesian coordinate systems (Cartesian coordinate systems ). Second, if you want to smooth the surface and remove the mesh, you only need to add the following after the drawing command:Shading interp. In this way, Matlab performs corresponding interpolation. Assume that you want to create a two-dimensional graph to simulate the effect of a 3D graph. Now, you can manually rotate the 3D graph into a two-dimensional graph and then add a colorbar.

The figure below shows the effect of removing the surf command from the grid.

 

Manually rotate and add a two-dimensional chart after the colorbar:



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.