在MATLAB中用箭头表示以极坐标表示的矢量场

时间:2017-09-14 01:11:15

标签: matlab

我想绘制以极坐标表示的以下矢量场:

E = r * R  % (i am using big R to represent r^ hat). 

该字段应类似于figure P3.20

enter image description here

1 个答案:

答案 0 :(得分:1)

最困难的部分是将极坐标转换为欧氏坐标:

[x,y] = meshgrid(-5:1:5,-5:1:5);

r = sqrt(x.^2 + y.^2); % r in function of (x, y)
theta = atan2(y, x); % theta in function of (x, y)

u = r.*cos(theta); % x component of the vector field
v = r.*sin(theta); % y component of the vector field

quiver(x, y, u, v)

enter image description here