%% Calculate Exponentially Scaled Modified Bessel Functions
% Calculate the scaled modified Bessel function of the first kind I_{\nu } \left(z\right)\cdot e^{-\left|\textrm{Re}\left\lbrack Z\right\rbrack \right|} for values of z in the interval \left\lbrack 0,20\right\rbrack and for orders \nu between 0 and 3.

z = linspace(0,20);
scale = 1;
Is = zeros(4,100);
for nu = 0:3
  Is(nu+1,:) = besseli(nu,z,scale);
end

%
% Plot all of the functions in the same figure. For large values of z, the scaled functions do not overflow the limits of double precision, extending their range of computability compared to the unscaled functions.

plot(z,Is)
legend('I_0','I_1','I_2','I_3')
title('Scaled Mod. Bessel Functions of the First Kind for $\nu \in \left[0, 3 \right]$','interpreter','latex')
xlabel('z','interpreter','latex')
ylabel('$e^{-|{z}|} \cdot I_\nu(z)$','interpreter','latex')

% Copyright 2018 The MathWorks, Inc.