Home>Article> What does meshgrid mean in matlab

What does meshgrid mean in matlab

藏色散人
藏色散人 Original
2020-05-11 11:10:39 25712browse

What does meshgrid mean in matlab

What does meshgrid mean in matlab?

meshgrid is a function in MATLAB (an application software) used to generate grid sampling points. It has a wide range of applications in using MATLAB for 3D graphics rendering.

Function function

Generate the grid data required to draw 3D graphics. When performing drawing operations on a computer, some sampling points are often required, and then the entire graphic is drawn based on these sampling points. When performing 3D drawing operations, three sets of data are involved: x, y, and z. The two sets of data x and y can be regarded as the coordinate pair (x, y)

obtained by sampling the coordinates in the Oxy plane.

For example, if you want to draw a 3D graphic in the area of "3<=x<=5, 6<=y<=9, z is not limited to the interval", if you only need integer coordinates as sampling points. We may need a matrix composed of coordinates like the following:

(3,9),(4,9),(5,9); (3,8),(4,8),(5,8); (3,7),(4,7),(5,7); (3,6),(4,6),(5,6);

In matlab, we can describe this coordinate matrix like this:

Independently separate the x coordinates of each point, we get:

3,4,5; 3,4,5; 3,4,5; 3,4,5;

Then separate the y coordinates of each point:

9,9,9; 8,8,8; 7,7,7; 6,6,6;

The corresponding x and y combination represents the above coordinate matrix. Meshgrid generates two matrices like this to simplify our operations. Then calculate z based on (x, y) and draw a three-dimensional graph.

Type type meshgrid in the Matlab command window to view the source code of the function (so you can understand the algorithm idea of meshgrid). Type doc meshgrid or help meshgrid to get the help documentation.

Syntax

[X,Y] = meshgrid(x,y)

Explanation: The value of each row of output X is the copied value of x; the value of each column of output Y is the copied value of y.

[X,Y]=meshgrid(x) is equivalent to [X,Y]=meshgrid(x,x)

[X,Y,Z]=meshgrid(x, y,z) generates a three-dimensional array, which can be used to calculate functions of three variables and draw three-dimensional stereograms

Related functions: plot3, mesh, surf, automesh, ndgrid

The above is the detailed content of What does meshgrid mean in matlab. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn