%% Plot Bessel Functions of Second Kind
% Define the domain.

z = 0:0.1:20;

%
% Calculate the first five Bessel functions of the second kind. Each row of Y contains the values of one order of the function evaluated at the points in z.

Y = zeros(5,201);
for i = 0:4
    Y(i+1,:) = bessely(i,z);
end

%
% Plot all of the functions in the same figure.

plot(z,Y)
axis([-0.1 20.2 -2 0.6])
grid on
legend('Y_0','Y_1','Y_2','Y_3','Y_4','Location','Best')
title('Bessel Functions of the Second Kind for $\nu \in [0, 4]$','interpreter','latex')
xlabel('z','interpreter','latex')
ylabel('$Y_\nu(z)$','interpreter','latex')

% Copyright 2015 The MathWorks, Inc.