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

z = 0:0.01:5;

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

K = zeros(5,501);
for i = 0:4
    K(i+1,:) = besselk(i,z);
end

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

plot(z,K)
axis([0 5 0 8])
grid on
legend('K_0','K_1','K_2','K_3','K_4','Location','Best')
title('Modified Bessel Functions of the Second Kind for $\nu \in [0,4]$','interpreter','latex')
xlabel('z','interpreter','latex')
ylabel('$K_\nu(z)$','interpreter','latex')

% Copyright 2015 The MathWorks, Inc.