Filter löschen
Filter löschen

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

4 Ansichten (letzte 30 Tage)
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 Kommentare
David Goodmanson
David Goodmanson am 19 Mai 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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Bessel functions finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by