如何在 MATLAB 中绘制类贝塞尔函数
我对 MATLAB 完全陌生,只知道一些基本命令。我的任务是绘制一个这样的函数:
I(T) = ((2*J(k*r*sin(T))/(k*r*sin(T))))^2
我在这里
T = angle
k = (2*pi*f)/c (f= frequency in Hz and c is speed of sound)
r = radius
J = bessel function first kind
解释一下:该函数代表空间中声波的功率。我已经尝试了很多次来绘制这个图,但我总是在图中得到一个点。
I'm totally new to MATLAB and I know only few basic commands. My task is to plot a function of this kind:
I(T) = ((2*J(k*r*sin(T))/(k*r*sin(T))))^2
where
T = angle
k = (2*pi*f)/c (f= frequency in Hz and c is speed of sound)
r = radius
J = bessel function first kind
I explain a bit: the function represent the power of a soundwave in the space. I've tried many times to plot this but i get always a single point in the plot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我假设您已经在
J
中定义了贝塞尔函数。如果不是,则第一类 Bessel 函数的 MATLAB 命令为besselj
。您还必须指定贝塞尔函数的阶数。您可以将匿名函数定义为
并将其绘制为
I assume you've defined your Bessel function in
J
. If not, the MATLAB command for a Bessel function of the first kind isbesselj
. You'll also have to specify the order of the Bessel function.You can define your anonymous function as
and plot it as
怎么样
what about
我终于找到了如何管理上述问题,这是我找到的解决方案,以防其他人可能需要它。
% 类似贝塞尔函数的图形生成的 MATLAB 指令 %
% 变量(固定值)%
k = 912.91
r = 0.0215
% 设置角度 theta % 的范围
theta = (-(2/3)*pi:pi/180:(2/3)*pi)
% 第一类贝塞尔函数的计算 %
J = besselj(1,k*r*sin(theta))
% 计算 I 函数 %
% 注意 ./ 和 .^ 运算符
I = ((2*J)./(k*r*sin(theta))).^2
% 现在使用绘图命令绘制结果
情节(θ,I)
I finally found how to manage the problem described above, here's the solution that i found, in case that other people may need it.
% MATLAB Istruction for graph generation of bessel like function %
% Variables (fixed values)%
k = 912.91
r = 0.0215
% Set the range for the angle theta %
theta = (-(2/3)*pi:pi/180:(2/3)*pi)
% Calculation of bessel function of first kind %
J = besselj(1,k*r*sin(theta))
% Calculation I function %
% notice the ./ and .^ operators
I = ((2*J)./(k*r*sin(theta))).^2
% now plot the results with the plot command
plot(theta,I)