MATLAB How to calculate Bessel function of order zero?

Click For Summary
To correctly calculate the Bessel function of order zero, the script provided requires the inclusion of element-wise operations. Specifically, the missing dots in the calculations for `h` should be added to ensure proper evaluation of the Bessel functions. The corrected line should use `.*` for multiplication and `./` for division, allowing for accurate computation across the array. After making these adjustments, the expected plot should align more closely with the reference figure. Properly implementing these changes will resolve the discrepancies in the output.
positroncascade
Messages
2
Reaction score
0
TL;DR
I try to plot a figure from an article. The analytical solution is given by Bessel function of order zero. I wrote my MATLAB script but it doesn't give results as expected. I need help on evaluating Bessel function of order zero.
Hello everyone.

I try to plot a figure from a journal article. I gave the equations in the inserted image. I wrote the script given below for that. I expect to obtain a plot like the one given on the left but I end up with something totally different. So, the values of ##I_{0}## and ##I_{1}## are probably wrong. How can I evaluate them correctly? Can you help me to spot my error?

Matlab:
phi = linspace(0.001, 1000, 1000000);
v = 2;
lRp = sqrt((1./phi).*((v+1)^2-1));
I1 = besseli(1,lRp);
I0 = besseli(0,lRp);
h = 1 - 2./lRp*(I1/I0);
plot(phi,h)
set(gca, 'XScale', 'log')

Thank you so much!

Capture.PNG
 
Last edited:
Physics news on Phys.org
You are missing dots in line 6. Fixed:
[CODE title="Matlab"]phi = linspace(0.001, 1000, 1000000);
v = 2;
lRp = sqrt((1./phi).*((v+1)^2-1));
I1 = besseli(1,lRp);
I0 = besseli(0,lRp);
h = 1 - 2./lRp.*(I1./I0);
plot(phi,h)
set(gca, 'XScale', 'log')[/CODE]
 
  • Like
Likes DrClaude and positroncascade

Similar threads

Replies
5
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K