Bessel function based equation returns NaN as output. Kindly check where I went wrong.
4 次查看(过去 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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/293871/image.jpeg)
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
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Bessel functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!