• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

matlab中 meshgrid 函数的用法

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
meshgrid 的使用方法:
[X,Y] = meshgrid(x,y) 将向量x和y定义的区域转换成矩阵X和Y,这两个矩阵可以用来表示mesh和surf的三维空间点以及两个变量的赋值。其中矩阵X的行向量是向量x的简单复制,而矩阵Y的列向量是向量y的简单复制。
 

Generate X and Y matrices for three-dimensional plots

Syntax:
[X,Y] = meshgrid(x,y)
[X,Y] = meshgrid(x)
[X,Y,Z] = meshgrid(x,y,z)

 

Description:

[X,Y] = meshgrid(x,y) transforms the domain specified by vectors x and y into arrays X and Y, which can be used to evaluate functions of two variables and three-dimensional mesh/surface plots. The rows of the output array X are copies of the vector x; columns of the output array Y are copies of the vector y.
[X,Y] = meshgrid(x) is the same as [X,Y] = meshgrid(x,x).
[X,Y,Z] = meshgrid(x,y,z) produces three-dimensional arrays used to evaluate functions of three variables and three-dimensional volumetric plots.

 
Remarks:

The meshgrid function is similar to ndgrid except that the order of the first two input and output arguments is switched. That is, the statement [X,Y,Z] = meshgrid(x,y,z)

produces the same result as [Y,X,Z] = ndgrid(y,x,z)

Because of this, meshgrid is better suited to problems in two- or three-dimensional Cartesian space, while ndgrid is better suited to multidimensional problems that aren\'t spatially based.
meshgrid is limited to two- or three-dimensional Cartesian space.

 

 

From:网易博客

详细解释:help meshgrid

meshgrid用于从数组a和b产生网格。生成的网格矩阵A和B大小是相同的。它也可以是更高维的。

[A,B]=Meshgrid(a,b)
生成size(b)Xsize(a)大小的矩阵A和B。它相当于a从一行重复增加到size(b)行,把b转置成一列再重复增加到size(a)列。因此命令等效于:

A=ones(size(b))*a;
B=b\'*ones(size(a))

如下所示:

>> a=[1:2]

a =

     1     2

>> b=[3:5]

b =

     3     4     5

>> [A,B]=meshgrid(a,b)

A =

     1     2
     1     2
     1     2


B =

     3     3
     4     4
     5     5

 

>> [B,A]=meshgrid(b,a)

B =

     3     4     5
     3     4     5


A =

     1     1     1
     2     2     2


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
matlab中Kmeans使用方法发布时间:2022-07-18
下一篇:
学习笔记124—MATLAB中regress函数用法(多元线性回归)发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap