user2924294
user2924294

Reputation: 37

Using bessel functions in MATLAB

I'm trying to put all of my functions from Excel workbook into MATLAB. I'm having an issue using bessel functions in MATLAB. I'm simply not getting the same results from MATLAB as I do in excel.

For example, in excel if I execute

=0.32*BESSELI(0.32,0)/2/BESSELI(0.32,1)

I get 1.012.

When I use the same approach in MATLAB

0.32*besseli(0.32,0)/2/besseli(0.32,1)

I simply get zero.

Can someone please help me integrate bessel functions into my MATLAB script so that they provide the same answer as they do when used in excel?

Upvotes: 1

Views: 478

Answers (2)

Alex Shesterov
Alex Shesterov

Reputation: 27565

MATLAB and Excel have the arguments of the besseli function in a different order.

The following expression (note the order of arguments changed):

0.32*besseli(0, 0.32)/2/besseli(1, 0.32)

will yield:

> ans =  1.0127

in MATLAB.

Upvotes: 3

Adriaan
Adriaan

Reputation: 18187

The documentation shows the formulae and show that if you use Z=0, which you have in your first besseli, you should get 0, which you do. The second call to besseli should not get you zero, and indeed it does not:

enter image description here

besseli(0.32,1)
ans =
    1.0744

I copied the following from the aforementioned documentation:

enter image description here

This shows that unless your nu (that Greek thing that looks like a v) is zero, your modified Bessel function of the first kind at Z=0 will be, in fact zero. On a side note: why are you doubly dividing and not simply writing

0.32*besseli(0.32,0)*besseli(0.32,1)/2

Upvotes: 2

Related Questions