0001 function J = besselj_dke_jd(N,Z,Mode)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
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;
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