我需要绘制这个函数
theta = (-pi:0.01:pi);
f = 3*10^9;
c = 299792458;
da = 2;
这是我的代码,但我不确定它是否正确。我不知道点标记应该在哪里。如何设置X轴递减?
beta = (2*pi*f)/c;
const= (da*beta)/2;
j= (cos(theta)+1).*(besselj(1,const*sin(theta))./(const*sin(theta)));
我的另一个问题是如何在极坐标中绘制此函数。
我做了这样的东西。
polar(theta,j);
是否可以旋转该函数(通过 y 轴)以获得 3D 绘图?
最佳答案
虽然我不会使用符号 j
,但事情对我来说是正确的作为变量,因为(如 i
所做的那样)它是虚数单位 ( sqrt(-1)
) 的符号。这样做会覆盖它,因此事情会一直有效,直到您不需要复数。
当您打算逐个元素地组合数组条目时,您应该使用诸如 ( .*
) 之类的逐元素操作,就像您为获得 F(\theta)
所做的那样。 .事实上,cos(theta)
是 theta
中包含的角度的余弦数组等等。
最后,您可以使用命令 Rotate 3D
旋转绘图在绘图窗口中。尽管如此,您有一个 2D 曲线 ( F(\theta)
),因此,您将继续旋转 2D 图形以获得它的某种透视图,仅此而已。要获得真实信息,您需要一个额外的因变量(或者我误解了您的问题?)。
编辑:现在我明白你的意思了,你想要 Surface of revolution围绕某个轴,我认为由于其中的对称性是 theta=0
.好吧,旋转曲面可以通过一些解析几何获得并绘制,例如通过使用 mesh
.检查一下:
% // 2D polar coordinate radius (your j)
Rad= (cos(theta)+1).*(besselj(1,const*sin(theta))./(const*sin(theta)));
Rad = abs(Rad); % // We need its absolute value for sake of clarity
xv = Rad .* cos(theta); % // 2D Cartesian coordinates
yv = Rad .* sin(theta); % // 2D Cartesian coordinates
phi = -pi:.01:pi; % // 3D revolution angle around theta = 0
% // 3D points of the surface
xf = repmat(xv',size(phi));
yf = yv' * cos(phi);
zf = yv' * sin(phi);
mesh(xf,yf,zf)
还可以添加图形效果
这是通过
完成的mesh(xf,yf,zf,'FaceColor','interp','FaceLighting','phong')
camlight right
和更精细的角度离散化 (1e-3)
.
关于matlab - 在matlab中绘制天线辐射特性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14172204/