简体   繁体   English

Mathematica中2d函数的矢量图

[英]Vector plot of 2d functions in mathematica

I am trying to plot 1/r (r-hat) using VectorPlot in Mathematica by decomposing r-hat into x-hat and y-hat. 我试图通过在Mathematica中使用VectorPlot将R-hat分解为x-hat和y-hat来绘制1 / r(r-hat)。

I am using: 我在用:

[Chi][x_, y_] := Sqrt[x^2 + y^2]

[Phi][x_, y_] := ArcTan[y/x]

and then plotting the above function in x,y plane. 然后在x,y平面上绘制上述函数。

But, for x<0 and y<0 , the vectors do not have the correct sign because the unit vectors have different sign in each of the quadrants. 但是,对于x<0y<0 ,向量没有正确的符号,因为单位向量在每个象限中具有不同的符号。 I tried defining a piecewise function to get around this without success. 我试图定义一个分段函数来解决这个问题,但没有成功。

VectorPlot[ 1/Sqrt[x x + y y] {Cos[ArcTan[x, y]], Sin[ArcTan[x, y]]}, 
          {x, -2, 2},  {y, -2, 2},
          RegionFunction -> Function[{x, y, vx, vy, n}, Sqrt[x x + y y] > 1/3], 
          VectorPoints -> 10]

Mathematica图形

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM