MATLAB: Am I getting unexpectedly large numbers in calculations in MATLAB

bessel function

Hi all,
I am trying to perform some operations using Bessel function and plot 'v' against 'r' (as defined in the adjacent image).
But when I am defining the function 'F' (from image) and evaluating it at certain points (which are roots of J2), I am getting unexpectedly large numbers and MATLAB is not performing simple mathematical operations on them on it's own.
My program for this is:
bessj2 = inline('besselj(2,x)');
for n = 1:10
z(n) = fzero(bessj2,[(n-1) n]*pi);
end
z(1)=[];
syms x;
F1=diff(besselj(1,x),x);
f1=besselj(0, z) - besselj(1, z)/z;
syms r t;
F=@(x,t)besselj(1,x).*(exp(x.*x*t/100)-1)./(x.*x);
f=eval(subs(F,x,z));
F2=besselj(1,z).*(1./z-1)./z;
F3=@(x,r,t)(besselj(1,x.*r).*exp(-x.*x*t./100).*(f+F2))./(f1.^2);
f3=eval(subs(F3,x,z));
f4=sum(f3);
v=@(r,t)2*f4;
ezplot(v,[0,1,0,10])
Please help me figure out a way to solve this problem.
Thank you.

Best Answer

Never eval() a symbolic expression. Symbolic expressions are in a language that is not MATLAB.
You need to symfun to construct your v. Your existing code for v ignores the inputs. When you name a dummy parameter in an anonymous function definition @(r,t) but do not use the parameter in the text of the anonymous function, then that does not bind to any symbolic variable you might happen to have with the same name.
Related Question