%% Exponentially Scaled Hankel Function
% Calculate the exponentially scaled Hankel function H_1^{\left(2\right)} \left(z\right){\;\cdot \;e}^{\textrm{iz}} on the complex plane and compare it to the unscaled function.
%
% Calculate the unscaled Hankel function of the second order on the complex plane. When z has a large positive imaginary part, the value of the function quickly diverges. This phenomenon limits the range of computable values.

k = 2;
nu = 1;
x = -5:0.4:15;
y = x';
z = x + 1i*y;
scaled = 1;
H = besselh(nu,k,z);
surf(x,y,imag(H))
xlabel('real(z)')
ylabel('imag(z)')

%
% Now, calculate H_1^{\left(2\right)} \left(z\right){\;\cdot \;e}^{\textrm{iz}} on the complex plane and compare it to the unscaled function. The scaled function increases the range of computable values by avoiding overflow and loss of accuracy when z has a large positive imaginary part.

Hs = besselh(nu,k,z,scaled);
surf(x,y,imag(Hs))
xlabel('real(z)')
ylabel('imag(z)')

% Copyright 2018 The MathWorks, Inc.