Use MATLAB three-dimensional graphics functions analytic basis meshgrid

Use MATLAB three-dimensional graphics functions analytic basis meshgrid

  Meshgrid in MATLAB function is used to generate the grid, use the function is:
  [X-, the Y] = meshgrid (X, Y); this is the most common kind of usage. x and y are two vectors. Use Example:
Here Insert Picture Description
Results:
Here Insert Picture Description
Here Insert Picture Description
  Each point corresponds to A in the x-axis coordinate points, each point corresponding to B in the y-axis coordinate point is, speaking somewhat abstract, drawing to explain below.
Is drawn out of the coordinates:
Here Insert Picture Description
the coordinates of the corresponding point:
Here Insert Picture Description
  in fact, the line A represents the coordinates from the first row to the last line of the x-axis value of the matrix A, the matrix A in accordance with that shown above:
Here Insert Picture Description
  B represents a from the first column to the last y-axis coordinate value of a B column matrix, the matrix B according to the figure is shown:
Here Insert Picture Description
  it is possible to know the nature of meshgrid function is to determine the value for each position x, y coordinate axis. This is very important when drawing the three-dimensional graph, since the three-dimensional map according actually x, y plane corresponds to each position on Z with a specific, then it is drawn out, the so-called three-dimensional view.
According to the above principle is simple to draw a three-dimensional graph, an example:

%% 学习画三维图形
% meshgrid 函数是用来生成一个网格
clear; clc; close all;
[x,y] = meshgrid(1:0.5:10,1:20);  % 生成网格
z = sin(x) + cos(y);
surf(x,y,z);  % 画图函数

Effect display:
Here Insert Picture Description
  the icon can be known, if the x, y coordinates of the more precise, the more delicate three-dimensional plot is drawn out.
Example:
Here Insert Picture Description
effect display:
Here Insert Picture Description

Guess you like

Origin www.cnblogs.com/zhicungaoyuan-mingzhi/p/12443256.html