the_aardavark
the_aardavark

Reputation: 1

Plotting Bessel functions

How do you plot a Bessel function (2d) of the 1st kind in Matlab?

Upvotes: 0

Views: 7990

Answers (2)

Ramashalanka
Ramashalanka

Reputation: 8864

If you mean a 2d plot, you could choose a few \nu and overlay, using, e.g.

nu=0:0.5:3;
[nuGrid,z]=meshgrid(nu,linspace(0,10,100));
myBessel=besselj(nuGrid,z);
plot(z,myBessel)
xlabel('\nu')
ylabel('z')
zlabel('J_\nu(z)')
legend(cellstr(num2str(nu')))

which gives:

alt text

If you mean a plot of the function of two variables, here is a way (you can replace mesh with surf if you want) :

[nu,z]=meshgrid(linspace(0,5,100),linspace(0,10,100));
myBessel=besselj(nu,z);
mesh(nu,z,myBessel)
xlabel('\nu')
ylabel('z')
zlabel('J_\nu(z)')

Here is the resulting plot:

alt text

Upvotes: 1

duffymo
duffymo

Reputation: 308938

Two parts to this:

  1. How to plot functions in MATLAB?
  2. How to evaluate a Bessel function over a given range?

Upvotes: 1

Related Questions