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

조회 수: 7 (최근 30일)
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
David Goodmanson
David Goodmanson 2020년 5월 19일
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.
Swathi S
Swathi S 2020년 5월 20일
Thank you David for your help. I will try this.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Bessel functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by