J0 = @(x) besselj ( 0, x );      % <- a "one line" function;
%
%  We happen to know there is a root of the J0 function
%  in each interval [0,pi], [pi,2pi], [2pi,3pi], ...
%
for n = 1 : 10
  z(n) = fzero ( J0, [ (n-1)*pi, n*pi] );
end
%
%  Plot the function and the 10 zeros we found.
%
x = linspace ( 0.0, 10.0*pi, 501 );
y = J0(x);
plot ( x, y, '-', ...
         x, 0*y, 'k:', ...
         z, zeros ( 1, 10 ), 'r.', ...
         'LineWidth', 3, 'Markersize', 50 );

axis ( [ 0.0, 10.0 * pi, -0.5, 1.0 ] );
grid on
xlabel ( '<-- X -->' );
ylabel ( '<-- Y -->' );
title ( 'Zeros of Bessel J0(x) function', 'Fontsize', 24 );

print ( '-djpeg', 'bessel_plot.jpg' );