besselj_dke_jd

PURPOSE ^

SYNOPSIS ^

function J = besselj_dke_jd(N,Z,Mode)

DESCRIPTION ^

 generates the Bessel function of the first kind, J_N(Z).
 
   - if Mode <> 0, gives the exact, Matlab generated function
   - if Mode == 0, gives the approximate value (Z/2)^N/N! valid for Z << 1

 Note: - N,Mode must have the same size as Z or be scalars.
       - N must contain integers
       - Z must be real for approximate formula

 by J. Decker 05/01/03

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function J = besselj_dke_jd(N,Z,Mode)
0002 %
0003 % generates the Bessel function of the first kind, J_N(Z).
0004 %
0005 %   - if Mode <> 0, gives the exact, Matlab generated function
0006 %   - if Mode == 0, gives the approximate value (Z/2)^N/N! valid for Z << 1
0007 %
0008 % Note: - N,Mode must have the same size as Z or be scalars.
0009 %       - N must contain integers
0010 %       - Z must be real for approximate formula
0011 %
0012 % by J. Decker 05/01/03
0013 %
0014 if nargin < 3
0015     error('Not enough arguments in besselj_dke_jd')
0016 end
0017 %
0018 SZ = size(Z);
0019 SN = size(N);
0020 SM = size(Mode);
0021 %
0022 if ~isequal(SN,SZ),
0023     if length(N) ~= 1
0024         error('N must be scalar or of the same size as Z')
0025     end
0026     N = repmat(N,SZ);
0027 end
0028 %
0029 if ~isequal(SM,SZ),
0030     if length(Mode) ~= 1
0031         error('Mode must be scalar or of the same size as Z')
0032     end
0033     Mode = repmat(Mode,SZ);
0034 end
0035 %
0036 if max(N(:) - floor(N(:))) > 0
0037     error('N must be integers')
0038 end
0039 %
0040 Mask_approx = (Mode == 0);
0041 %
0042 if ~all(isreal(Mask_approx(:).*Z(:))),
0043     error('Z must be real for approximate formula')
0044 end
0045 %
0046 Z = Z.*(N >= 0) + (-1).^N.*(N <0).*Z; % J_{-n}(Z) = J_(n)((-1)^n*Z)
0047 N = abs(N);
0048 %
0049 J = zeros(SZ);
0050 if ~all(Mask_approx),
0051     J(~Mask_approx) = besselj(N(~Mask_approx),Z(~Mask_approx));
0052 end
0053 J(Mask_approx) = (Z(Mask_approx)/2).^N(Mask_approx)./fact_dke_jd(N(Mask_approx));
0054 %

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.