meshgrid Cartesian grid in 2-D/3-D space
[X,Y] = meshgrid(xgv,ygv) replicates the grid vectors xgv and ygv to
produce the coordinates of a rectangular grid (X, Y). The grid vector
xgv is replicated numel(ygv) times to form the columns of X. The grid
[X,Y] = meshgrid(xgv,ygv) replicates the grid vectors xgv and ygv to
produce the coordinates of a rectangular grid (X, Y). The grid vector
xgv is replicated numel(ygv) times to form the columns of X. The grid
vector ygv is replicated numel(xgv) times to form the rows of Y.
该函数用来产生2维或者三维坐标。上面英文意思是:xgv与ygv是两个向量,返回值X,Y则是两个矩阵.X矩阵由xgv向量被复制numel(ygv)次产生,Y矩阵由ygv向量被复制numel(xgv)次得来.(numel(xgv)指向量xgv元素的个数)
注意的是:矩阵X,Y的行列数相等。
xgv = 1:2;
ygv = 4:6;
[X,Y] = meshgrid(xgv,ygv)
结果:
X =
1 2
1 2
1 2
Y =
4 4
5 5
6 6
由结果看出X,Y行列相等,我认为是: X由xgv纵向复制了numel(ygv),Y由ygv转置后横向复制numel(xgv)次!
</pre><pre name="code" class="plain">本人初学,写该文主要是加深记忆,如有错误或者不足支持还望指出!一起学习,共同进步!谢谢!