matlab ;每日学习 3D作图 surf meshgrid…

作一个3D函数图

x=-10:0.1:10;

y=x;

[X,Y]=meshgrid(x,y);%生成坐标网格分量矩阵X和Y

figure,mesh(X,Y,sin(X+Y));%运行结果如下图1

figure,surf(X,Y,sin(X+Y)),shadinginterp;%运行结果如下图2

matlab <wbr>每日学习 <wbr>3D作图 <wbr> <wbr>surf <wbr>mesh <wbr>meshgrid函数

图1

matlab <wbr>每日学习 <wbr>3D作图 <wbr> <wbr>surf <wbr>mesh <wbr>meshgrid函数

图2



 用一种更简单的方式

 [X,Y]=meshgrid(-10:.1:10);

mesh(X,Y,sin(X.*Y));

 

 

MESHGRID   X and Y arrays for3-D plots.
    [X,Y] =MESHGRID(x,y) transforms the domain specified by vectors
    x and y intoarrays X and Y that can be used for the evaluation
    of functionsof two variables and 3-D surface plots.
    The rows ofthe output array X are copies of the vector x and
    the columnsof the output array Y are copies of the vector y.
 
    [X,Y] =MESHGRID(x) is an abbreviation for [X,Y] = MESHGRID(x,x).
    [X,Y,Z] =MESHGRID(x,y,z) produces 3-D arrays that can be used to
    evaluatefunctions of three variables and 3-D volumetric plots.
 
    For example,to evaluate the function  x*exp(-x^2-y^2) overthe
   range  -2 < x <2,  -2 < y <2,
 
       [X,Y] = meshgrid(-2:.2:2, -2:.2:2);
       Z = X .* exp(-X.^2 - Y.^2);
       surf(X,Y,Z)
 
    MESHGRID islike NDGRID except that the order of the first two input
    and outputarguments are switched (i.e., [X,Y,Z] = MESHGRID(x,y,z)
    produces thesame result as [Y,X,Z] = NDGRID(y,x,z)).  Becauseof
    this,MESHGRID is better suited to problems in cartesian space,
    while NDGRIDis better suited to N-D problems that aren't spatially
   based.  MESHGRID is also limited to 2-D or3-D.
 
    Classsupport for inputs X,Y,Z:
      float: double, single

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值