Bessel function based equation returns NaN as output. Kindly check where I went wrong.

7 views (last 30 days)
I have attached the equation in image format and given the code below. Kindly help me find in which function i did mistake- bessel or sinh or exp.
EQUATION:
.
CODE:
I1=@(x) besselj(1,x.*sqrt(i/j)).*besselj(1,x.*sqrt(j/i)).*besselj(0,x.*(s/(sqrt(i.*j)))).*((sinh(x.*(aw/i).*sqrt(i/j)))/(x.*(aw/i).*sqrt(i/j))).*((sinh(x.*(aw/j).*sqrt(j/i)))/(x.*(aw/j).*sqrt(j/i))).*(exp(-x.*(z/(sqrt(i.*j)))))
I=integral(I1,0,Inf)
M=pi*u*n1*n2*sqrt(i*j)*I
OUTPUT:
NaN
  2 Comments
David Goodmanson
David Goodmanson on 19 May 2020
Hi Swathi,
this is almost certainly happening because sinh(z)/z = 1 at z=0, but sinh(z) and z when calculated separately and divided, gives 0/0 =nan. You need to create a function that calculates sinh(z)/z and replaces nan by 1 at z=0.
Incidentally you are missing dots at a couple of locations:
((sinh(x.*(aw/i).*sqrt(i/j)))./(x.*(aw/i).*sqrt(i/j)))
^
and similarly for the other sinh function. Of course this doesn't get you out of the nan problem, it just fixes up the element by element division.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!