Matlab 绘制矢量图

经常会用到matlab计算矢量图,我们希望可以直观的表示出来,通过观察来对比。

因此,希望可以绘制出矢量图。

 

matlab提供了矢量图绘制函数:quiver()

matlab help给出了说明:

 QUIVER Quiver plot.
    QUIVER(X,Y,U,V) plots velocity vectors as arrows with components (u,v)
    at the points (x,y).  The matrices X,Y,U,V must all be the same size
    and contain corresponding position and velocity components (X and Y
    can also be vectors to specify a uniform grid).  QUIVER automatically
    scales the arrows to fit within the grid.
 
    QUIVER(U,V) plots velocity vectors at equally spaced points in
    the x-y plane.
 
    QUIVER(U,V,S) or QUIVER(X,Y,U,V,S) automatically scales the
    arrows to fit within the grid and then stretches them by S.  Use
    S=0 to plot the arrows without the automatic scaling.
 
    QUIVER(...,LINESPEC) uses the plot linestyle specified for
    the velocity vectors.  Any marker in LINESPEC is drawn at the base
    instead of an arrow on the tip.  Use a marker of '.' to specify
    no marker at all.  See PLOT for other possibilities.
 
    QUIVER(...,'filled') fills any markers specified.
 
    QUIVER(AX,...) plots into AX instead of GCA.
 
    H = QUIVER(...) returns a quivergroup handle.
 
    Backwards compatibility
    QUIVER('v6',...) creates line objects instead of a quivergroup
    object for compatibility with MATLAB 6.5 and earlier.
  
    Example:
       [x,y] = meshgrid(-2:.2:2,-1:.15:1);
       z = x .* exp(-x.^2 - y.^2); [px,py] = gradient(z,.2,.15);
       contour(x,y,z), hold on
       quiver(x,y,px,py), hold off, axis image

 

例如要绘制[zx,zy]

zx 为x方向矢量

zy 为y方向矢量

(minx, maxx)为x方向取值区间

(miny, maxy)为y方向取值区间

 

[xx,yy]=meshgrid(minx:maxx, miny:maxy);
quiver(xx,yy,zx,zy)

 

  • 0
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值