开发者

How to plot a bessel-like function in MATLAB

开发者 https://www.devze.com 2023-03-21 09:03 出处:网络
I\'m totally new to MATLAB and I know only few basic commands. My ta开发者_JAVA百科sk is to plot a function of this kind:

I'm totally new to MATLAB and I know only few basic commands. My ta开发者_JAVA百科sk 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.


I assume you've defined your Bessel function in J. If not, the MATLAB command for a Bessel function of the first kind is besselj. You'll also have to specify the order of the Bessel function.

You can define your anonymous function as

f=@(t,k,r)(2*besselj(0,k*r*sin(t))./(k*r*sin(t))).^2

and plot it as

T=linspace(0,pi,100);%# a sample angle vector
plot(T,f(T,k,r))     %# where k and r are values you'll have to provide


what about

I = ((2*J(k*r*sin(T))./(k*r*sin(T)))).^2


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号