Implementing MATLAB's besselj function
Afficher commentaires plus anciens
Hi,
I've been trying to learn how to implement a Bessel function of the 1st kind. I understand that this function is provided in the MATLAB library of functions, "besselj(nu,Z)". The reason I am trying to implement it is to become more familiar with the formula, and how to program formula's in MATLAB.
I have come across the definition of the Bessel function of the 1st kind in various text, and also in the MATLAB documentation of the besselj function. When attempting to implement the formula myself, and then plot against MATLAB's implementation of the function I hit some errors. I'm wondering if anyone here can perhaps explain in a bit more detail how MATLAB have implemented this function?
When I view the graph of the in-built function 'besselj', regardless of the values of 'z', the graph continues fine, as it should. (You have no control of the value 'k' when calling MATLAB's besselj function). When I view the graph of my own implementation of the formula (defined in the MATLAB definition section of the documentation for besselj) I get strange discontinuities for large 'z' values. Whether I use a large or small value for 'k' it never converges to be the same as the output from the besselj function alone. If I have a small upper value of 'z' set to say 20, I can easily get a match between the output of besselj and my own implementation.
I suspect there may be a way of defining an optimum value for 'k' depending on the largest 'z' value?! Can someone perhaps clarify this for me?
Thank you!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Special Functions dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!