How can I evaluate a bessel function inside an integral?
18 ビュー (過去 30 日間)
古いコメントを表示
I need to do a definite integral involving a Bessel function but I cannot get it evaluated. I've already tried with eval() and subs() but the result is the same.
This is only a part of a more complex situation related to radiated electric and magnetic fields I'm working on but a simplified version of the problem could be this code:
>> syms x
>> f(x) = cos(x)*besselj(0,x*cos(x)*5);
>> integral = int(f,x,0,pi/2)
integral =
int(cos(x)*besselj(0, 5*x*cos(x)), x, 0, pi/2)
How could I obtain a numeric solution?
Thanks!
0 件のコメント
回答 (1 件)
John D'Errico
2018 年 2 月 11 日
編集済み: John D'Errico
2018 年 2 月 11 日
That MATLAB returns the integral just means that no analytical solution was found. But if you need only find a NUMERICAL result, then vpaintegral will suffice for this.
help vpaintegral
It is fairly new as I recall, so unless you have a recent release, this will fail.
vpaintegral(f,x,0,pi/2)
ans =
0.296334
However, a really bad idea is to use integral as the variable name, since that prevents you from using the function integral.
In fact, there is ABSOLUTELY no good reason to need to use symbolic tools at all. The function integral is fully sufficient to compute this too, HAD you not prevented that by defining a variable named integral.
f = @(x) cos(x).*besselj(0,x.*cos(x)*5);
integral(f,0,pi/2)
ans =
0.296334454079053
Note my use of the .* operator in the computation of f.
4 件のコメント
Stephen23
2018 年 2 月 13 日
"I admit that I come from the old days of MATLAB, when the software arrived on a 3.5 inch floppy..."
But still keeping up with new developments! I always enjoy your insights, analyses, and observations, so please keep up the excellent submissions. +1
Karan Gill
2018 年 2 月 13 日
And as a doc writer, I can't help but point out the doc :) As Stephen says, thanks for all the help around here.
参考
カテゴリ
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!